%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/nailstv/public_html/
Upload File :
Create Path :
Current File : /home/nailstv/public_html/csatorna.php

<?php

require_once 'config/config.php';

$p['title'] = '';
$p['desc'] = '';
$p['keywords'] = '';
$p['pagename'] = 'Channels';

if(!empty($uri[1])) {
    $u = explode('.', $uri[1]);
    $_GET['id'] = end(explode('-', $u[0]));
    if(!is_numeric($_GET['id'])){
        $_GET['view'] = $_GET['id'];
        unset($_GET['id']);
    }
}

$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)
{
    $db = Registry::get('db');

    $c = new Content();

    if(isset($_GET['id'])){
        $db = Registry::get('db');

        settype($_GET['id'], 'integer');
        $bind = array($_GET['id']);
        $sql = "SELECT v.id, v.cim, v.datum, v.hossz, v.file, v.file_mp4, v.osszes_nezettseg as nezettseg, /*COUNT(vn.id) as nezettseg,*/ ka.url, v.szoveg, v.leiras, /*vtvszf.szazalek as ertekeles,*/ v.file, k.file as kep, k.id as kep_id, v.title, v.description, v.keywords, ka.nev as kategoria_nev, ka.url as kategoria_url
				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
				WHERE v.storno = 'f'
					AND v.aktiv = 't'
					AND v.id = ?
				GROUP BY v.id";

        $row = $db->GetRow($sql, $bind);


        if(empty($row['id'])) {
            header("Location: " . Registry::get('wwwroot') . "/csatornak");
            die;
        } else {

            //mobile_detect
            require_once 'include/Mobile_Detect.php';
            $detect = new Mobile_Detect;
            $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');

            if(($detect->isMobile() || $detect->isTablet())){
                $row['file'] = $row['file_mp4'];
                $c->assign('isios', true);
            }

            $row['url'] = $row['url'] . '/' . String::fancyurl($row['cim']) . '-' . $row['id'];
            $row['hossz'] = substr($row['hossz'], 0, 5);
            $row['ertekeles'] = intval($row['ertekeles']);
            $row['datum'] = str_replace('-','.',$row['datum']);

            $row['cimkek'] = getCimkek($row['id']);

            $c->assign('video', $row);
            $c->assign('kapcs_videok', kapcs_videok($row['id']));
            $c->assign('kapcs_termekek', kapcs_termekek($row['id'], $c));
            $c->assign('hasonlo_videok', hasonlo_videok($row['id']));

            $c->assign('fejlec_banner', Page::banner(1,'fejlec'));

            Registry::get('page')->assign('title', $row['title']);
            Registry::get('page')->assign('description', $row['description']);
            Registry::get('page')->assign('keywords', $row['keywords']);

            /* facebook beállítások*/

            $links['title'] = $row['cim'];
            $links['url'] = urlencode(Registry::get('wwwroot') . '/'.$row['url']);
            $links['description'] = $row['description'];
            $links['image'] = Registry::get('wwwroot') . '/video/'.$row['id'].'/180_105/' . $row['kep'];

            $row['links'] = $links;

            //to meta
            Registry::get('page')->assign('facebook_share', $row['links']);

            insertNezes($row['id']);
        }
    } elseif(!empty($_GET['view'])){
        // nézetek
        $bind = array($uri[0]);
        $sql = "SELECT id
				FROM kategoria
				WHERE url = ?
					AND aktiv = 't'
					AND storno = 'f'";
        $row = $db->GetRow($sql, $bind);

        if(!empty($row['id'])){

            kategoria($row['id'], $c);

            switch($_GET['view']){
                case 'uj':
                    getVideosByDatum($row['id'], $c);
                    break;
                case 'nezettseg':
                    $tabla = 'vt_video_nezettseg_full';
                    getVideosByNezettseg($row['id'], $c, $tabla);
                    break;
                case 'nezettseghavi':
                    $tabla = 'vt_video_nezettseg_havi';
                    getVideosByNezettseg($row['id'], $c, $tabla);
                    break;
                case 'nezettsegheti':
                    $tabla = 'vt_video_nezettseg_heti';
                    getVideosByNezettseg($row['id'], $c, $tabla);
                    break;
                case 'nezettsegnapi':
                    $tabla = 'vt_video_nezettseg_napi';
                    getVideosByNezettseg($row['id'], $c, $tabla);
                    break;
                case 'ertekeles':
                    $tabla = 'vt_video_szavazas_full';
                    getVideosByErtekeles($row['id'], $c, $tabla);
                    break;
                case 'ertekeleshavi':
                    $tabla = 'vt_video_szavazas_havi';
                    getVideosByErtekeles($row['id'], $c, $tabla);
                    break;
                case 'ertekelesheti':
                    $tabla = 'vt_video_szavazas_heti';
                    getVideosByErtekeles($row['id'], $c, $tabla);
                    break;
                case 'ertekelesnapi':
                    $tabla = 'vt_video_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_video_kedvenc_full';
                    getVideosByKedvencszam($row['id'], $c, $tabla);
                    break;
                case 'kedvenchavi':
                    $tabla = 'vt_video_kedvenc_havi';
                    getVideosByKedvencszam($row['id'], $c, $tabla);
                    break;
                case 'kedvencheti':
                    $tabla = 'vt_video_kedvenc_heti';
                    getVideosByKedvencszam($row['id'], $c, $tabla);
                    break;
                case 'kedvencnapi':
                    $tabla = 'vt_video_kedvenc_napi';
                    getVideosByKedvencszam($row['id'], $c, $tabla);
                    break;

                default:
                    die('????');
                    break;
            }

        } else {
            //eldob
            header("Location: " . Registry::get('wwwroot') . "/csatornak");
            die;
        }
    } else {

        $bind = array($uri[0]);
        $sql = "SELECT id, title, description, keywords
				FROM kategoria
				WHERE url = ?
					AND aktiv = 't'
					AND storno = 'f'";
        $row = $db->GetRow($sql, $bind);

        if(!empty($row['id'])){
            $bind = array($row['id']);

            $sql = "SELECT id FROM kategoria WHERE parent_id = ?";
            $fokategoria = $db->GetArray($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']) && empty($fokategoria)){
            //alkategória - videó lista
            $kat = kategoria($row['id'], $c);
            videok($kat['id'], $c);
        } elseif(!empty($row['id']) && !empty($fokategoria)) {
            //főkategória
            kategoria($row['id'], $c, false);
            $c->assign('alkategoriak', kategoriaList($row['id']));
        } else {
            //eldob
            header("Location: " . Registry::get('wwwroot') . "/csatornak");
            die;
        }
    }

	//setcookie( 'dev0603_debug', 'true', time() + (86400 * 30 * 12), "/" );
	if ( $_SERVER['REMOTE_ADDR'] == '188.227.228.228' && isset($_COOKIE['dev0603_debug']) )
	{
		/*
		echo '<pre>';
		print_r( $row );

		die('-');
		*/
	}

    return $c->fetch('csatorna.tpl.html');
}

function kategoriaList($parent_id)
{
    $db = Registry::get('db');

    $bind = array($parent_id);

    $sql = "SELECT k.nev, k.szoveg, k.file, k.url
			FROM kategoria k
			WHERE k.storno = 'f'
				AND k.aktiv = 't'
				AND k.parent_id = ?";
    $alkategoriak = $db->GetArray($sql, $bind);

    return $alkategoriak;
}

function kategoria($id, $c)
{
    $db = Registry::get('db');

    $bind = array($id);

    $where = '';

    $sql = "SELECT *
			FROM kategoria
			WHERE id = ?
				AND storno = 'f'
				AND aktiv = 't'
				".$where."";
    $kat = $db->GetRow($sql, $bind);

    $c->assign('kategoria', $kat);

    return $kat;
}

function videok($kat_id, $c)
{
    $db = Registry::get('db');

    $bind = array($kat_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
			WHERE v.storno = 'f'
				AND v.aktiv = 't'
				AND v.kategoria_id = ?
				AND ka.storno = 'f'
			GROUP BY v.id
			ORDER BY 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']);
    }

    $c->assign('videok', $videok);

    return;
}

function kapcs_videok($id)
{
    $db = Registry::get('db');

    $bind = array($id);

    $sql = "SELECT v.id, v.cim, v.datum, v.hossz,v.osszes_nezettseg as nezettseg, /* COUNT(vn.id) as nezettseg,*/ ka.url, vtvszf.szazalek as ertekeles, k.file, k.id as kep_id
			FROM video_to_video vtv
			LEFT JOIN video v ON v.id = vtv.kapcs_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 vtv.video_id = ?
				AND ka.storno = 'f'
			GROUP BY v.id
			ORDER BY v.sorrend";

    $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']);
    }

    return $videok;
}

function getCategoryUrl($id = null)
{
	if(!isset($id))
		return '';

	$db = Db::kdb('cncom_shop');

	$bind = array(1, $id);
	$sql = "SELECT s.url
                FROM kategoria k
                LEFT JOIN kategoria_seo s ON s.kategoria_id = k.id AND s.site_id = ?
                LEFT JOIN termek_gyujto_kategoria tgyk ON tgyk.kategoria_id = k.id
            	LEFT JOIN termek_gyujto_altermekek tgya ON tgya.termek_gyujto_id = tgyk.termek_gyujto_id
                WHERE k.storno = 'f'
                AND k.tipus = 'termek'
                AND k.aktiv = 't'
                AND tgya.termek_gyujto_id = ?";
	$row = $db->GetRow($sql, $bind);

	return 'http://www.crystalnails.com/webshop/'.$row['url'];
}
function getProductUrl($id = null, $type = 'termek')
{
	if(!isset($id))
		return '';

	$db = Db::kdb('cncom_shop');
	$bind = array($id);

	if($type == 'termek')
	{
		$sql = "SELECT tgy.id,t.nev, tgys.url,
                ks.url AS kategoria_url, t.id AS termek_id, t.nev as termek_nev
                FROM termek t
                LEFT JOIN termek_gyujto_altermekek tgya ON tgya.termek_id = t.id
                LEFT JOIN termek_gyujto tgy ON tgy.id = tgya.termek_gyujto_id
                LEFT JOIN termek_gyujto_seo tgys ON tgys.termek_gyujto_id = tgy.id
                LEFT JOIN termek_gyujto_kategoria tgyks ON tgyks.termek_gyujto_id = tgy.id AND tgyks.def = 't'
                LEFT JOIN kategoria_seo ks ON tgyks.kategoria_id = ks.kategoria_id
                WHERE t.storno = 'f'
                    AND tgy.storno = 'f'
                    AND tgy.aktiv = 't'
					AND t.id = ?
                LIMIT 1";
	}
	else
	{
		$sql = "SELECT tgy.id, tgy.bevezeto, tgy.nev, tgys.url,
                ks.url AS kategoria_url
                FROM termek_gyujto tgy
                LEFT JOIN termek_gyujto_seo tgys ON tgys.termek_gyujto_id = tgy.id
                LEFT JOIN termek_gyujto_kategoria tgyks ON tgyks.termek_gyujto_id = tgy.id AND tgyks.def = 't'
                LEFT JOIN kategoria_seo ks ON tgyks.kategoria_id = ks.kategoria_id
                WHERE tgy.storno = 'f'
                    AND tgy.aktiv = 't'
                    AND tgy.id = ?
                LIMIT 1";
	}


	$product = $db->GetRow($sql, $bind);

	if(!isset($product['kategoria_url']) && !isset($product['id']))
		return false;

	if($type == 'termek')
	{
		if(!empty($product['url']))
			$url = $product['url'];
		else
			$url = strtolower(String::fancyurl($product['nev']));

		$product_url = 'http://www.crystalnails.com/webshop/ '. $product['kategoria_url'] . '/' . $url . '-' . $product['id'] . '_' . $product['termek_id'];
		$product_url = str_replace(' ', '', $product_url);
	}
	else
	{
		$url = $product['url'];

		$product_url = 'http://www.crystalnails.com/webshop/ '. $product['kategoria_url'] . '/' . $url . '-' . $product['id'];
		$product_url = str_replace(' ', '', $product_url);
	}

	return trim($product_url);
}


function getProductPicture($id = null,$type = 'termek')
{
	if(!isset($id))
		return '';

	$db = Db::kdb('cncom_shop');
	$bind = array($id);

  if($type == 'gyujto')
	{
		$sql = "SELECT k.file FROM imageConnection ic
  					LEFT JOIN images k ON k.id = ic.image_id
  					WHERE ic.galeria_id = ?
  						AND ic.tipus = 'termek_gyujto'
  				  AND ic.def = 't'
  					AND k.storno = 'f' ";


	}
	else
	{
		$sql = "SELECT k.file FROM imageConnection ic
  					LEFT JOIN images k ON k.id = ic.image_id
  					WHERE ic.galeria_id = ?
  						AND ic.tipus = '".$type."'
  				  AND ic.def = 't'
  					AND k.storno = 'f' ";
	}


	$termekek = $db->GetArray($sql, $bind);

	if(isset($termekek[0]['file']))
		return 'http://www.crystalnails.com/webshop/img/galeria/250/'.$termekek[0]['file'];
	else
		return false;
}


function kapcs_termekek($id, $c)
{
    $db = Registry::get('db');
    $kdb = Db::kdb('cncom_shop');

    $bind = array($id);
    /*k.file AS kep, kp.kepzes_id
            FROM kepzes e
            " . $db->joinDefPic('kepzes', 'e') . "*/
    $sql = "SELECT t.id,t.nev, t.link,t.kep_link, t.ext_id,t.ext_id_cat,t.ext_id_col
			FROM termekek t
			WHERE t.storno = 'f'
				AND t.aktiv = 't'
				AND t.video_id = ?
				AND t.tipus = 'video'
			ORDER BY t.sorrend";

    $termekek = $db->GetArray($sql, $bind);



    $product_ids = array();
    if(!empty($product_ids))
    {
        foreach( $termekek as $termek)
        {
            $e = explode('-',$termek['link']);
            $product_ids[] = intval(end($e));
        }
    }

    $sql2 = "
            SELECT galeria_id,file
            FROM `kep`
            WHERE `galeria_id` IN(".implode(',',$product_ids).")
            AND tipus = 'termek'
            AND `def` = 't'
        ";

    $r2 = $kdb->GetAssoc( $sql2 );

    if(!empty($termekek))
    {
        foreach($termekek as &$termek)
        {
            $e = explode('-',$termek['link']);
            $p_id = intval(end($e));
            $termek['kep'] = $r2[$p_id];

            if(!empty($termek['ext_id_cat']) && ($termek['ext_id_cat'] != 0))
            {
                $termek['link'] = getCategoryUrl($termek['ext_id_cat']);
                $termek['kep'] = getProductPicture($termek['ext_id_cat'],'termek_gyujto');
            }
            else if(!empty($termek['ext_id']) && ($termek['ext_id'] != 0))
            {
                $termek['link'] = getProductUrl($termek['ext_id']);
                $termek['kep'] = getProductPicture($termek['ext_id']);
            }
            else if(!empty($termek['ext_id_col']) && ($termek['ext_id_col'] != 0))
            {
	            $termek['link'] = getProductUrl($termek['ext_id_col'],'gyujto');
	            $termek['kep'] = getProductPicture($termek['ext_id_col'],'gyujto');
            }

            if(isset($_SESSION['mentor'])){
                $link = explode(".", $termek['link']);
                $link = array_slice($link, 1);
                $link_elotag = array("http://" . $_SESSION['mentor']);
                $link = array_merge($link_elotag, $link);
                $termek['link'] = implode('.', $link);
                //print_r($termek['link']); die;
            }
        }
    }


    if(empty($termekek)){
        $c->assign('jobb_banner', Page::banner(2,'jobb'));
    }

    return $termekek;
}

function hasonlo_videok($id)
{
    $db = Registry::get('db');

    $bind = array($id);

    $sql = "SELECT v.cim
			FROM video v
			WHERE v.id = ?";
    $alap_video = $db->GetRow($sql, $bind);

    $alap_video = explode(' ', $alap_video['cim']);

    $alap_video = array_unique($alap_video);

    $kulcsszavak = $alap_video;

    $vagott_szavak = array_slice($kulcsszavak, 0, 3);

    $kulcsszavak = $vagott_szavak;


    $query_parts = array();

    $nelegyenbenne = array('köröm', 'műköröm', 'zselé', 'porcelán');
    //print_r($kulcsszavak); print '<br>';
    $vedd_ki = false;
    foreach($kulcsszavak as $key=>$val){
        if(in_array($val, $nelegyenbenne)){
            unset($kulcsszavak[$key]);
            $vedd_ki = true;
        }
        if(mb_strlen($val, 'UTF-8')<5){
            unset($kulcsszavak[$key]);
            continue;
        }
        if(!$vedd_ki){
            $query_parts[] = "'%".mysql_real_escape_string($val)."%'";
        }
        $vedd_ki = false;
    }

    //print_r($kulcsszavak); print '<br>'; die;
    //$keres1 = implode(' OR v.keres LIKE ', $query_parts);
    foreach($query_parts as $k=>$v){
        if($v=="'%%'"){
            unset($query_parts[$k]);
        }
    }

    $keres2 = implode(' OR v.cim LIKE ', $query_parts);

    $bind[] = $id;
    $bind[] = $id;


    $sql = "SELECT v.id, v.cim, v.datum, v.hossz, ka.url, v.osszes_nezettseg as nezettseg, vtvszf.szazalek as ertekeles, k.file, k.id as kep_id
			FROM video v
			" . $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
			WHERE v.storno = 'f'
				AND (v.cim LIKE {$keres2} AND v.id != ? AND v.aktiv = 't')
				AND v.id != ?
				AND ka.storno = 'f'
				AND v.aktiv = 't'
			ORDER BY v.datum DESC, v.sorrend
			LIMIT 0,8";
    $hasonlo = $db->GetArray($sql, $bind);

    if(!empty($hasonlo))
    {
        foreach($hasonlo as $key=>$val){
            $hasonlo[$key]['url'] = $val['url'] . '/' . String::fancyurl($val['cim']) . '-' . $val['id'];
            $hasonlo[$key]['hossz'] = substr($val['hossz'], 0, 5);
            $hasonlo[$key]['ertekeles'] = intval($val['ertekeles']);
            $hasonlo[$key]['datum'] = str_replace('-','.',$val['datum']);
/*
            $bind = array($val['id']);
            $sql = "SELECT COUNT(vn.id) as nezettseg
					FROM video v
					LEFT JOIN video_nezettseg vn ON vn.video_id = v.id
						WHERE v.id = ?";

            $row = $db->GetRow($sql, $bind);
            $hasonlo[$key]['nezettseg'] = $row['nezettseg'];*/
        }
    }

    return $hasonlo;
}

function insertNezes($id)
{
    $db = Registry::get('db');

    $most = date("Y-m-d H:i:s");
    $sql = "INSERT INTO `video_nezettseg`(`video_id`, `datum`) VALUES ('". $id ."','". $most ."')";

    $db->query($sql);

    $sql = "INSERT INTO `most_nezik`(`video_id`) VALUES ('". $id ."')";

    $db->query($sql);

    $sql = "UPDATE video SET osszes_nezettseg = osszes_nezettseg + 1, napi_nezettseg= napi_nezettseg + 1, heti_nezettseg = heti_nezettseg + 1 , havi_nezettseg = havi_nezettseg + 1 WHERE id = '". $id ."'";

    $db->query($sql);

    return;
}

function getCimkek($id)
{
    $db = Registry::get('db');

    $bind = array($id);

    $sql = "SELECT c.nev, c.url, c.id
			FROM cimke_to_video ctv
			LEFT JOIN cimkek c ON c.id = ctv.cimkek_id
			WHERE ctv.video_id = ?
				AND c.storno = 'f'
				AND c.aktiv = 't'";

    $cimkek = $db->GetArray($sql, $bind);

    return $cimkek;
}

function getVideosByDatum($kat_id, $c)
{
    $db = Registry::get('db');

    $bind = array($kat_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
			WHERE v.storno = 'f'
				AND v.aktiv = 't'
				AND v.kategoria_id = ?
				AND ka.storno = 'f'
			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 = getVideok($kat_id);
    }

    $c->assign('videok', $videok);

    $sql = "SELECT k.nev, k.title, k.description, k.keywords FROM kategoria k WHERE k.storno = 'f' AND k.id = ?";
    $kat_seo = $db->GetRow($sql, $bind);

    $title = "Newest videos - " . $kat_seo['nev'];
    $keywords = "Newest videos, " . strtolower($kat_seo['nev']);
    $description = "Newest videos in the  - " . $kat_seo['nev'] . " category. Newest Step by Step videos.";

    Registry::get('page')->assign('title', $title);
    Registry::get('page')->assign('description', $description);
    Registry::get('page')->assign('keywords', $keywords);

    return;
}

function getVideosByNezettseg($kat_id, $c, $tabla)
{
    $db = Registry::get('db');

    $bind = array($kat_id);

    if(empty($tabla)){
        $tabe = "vt_video_nezettseg_full";
    }

    $sql = "SELECT v.id, v.cim, v.datum, v.hossz, v.osszes_nezettseg as nezettseg, /* 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 */
			WHERE v.storno = 'f'
				AND v.aktiv = 't'
				AND v.kategoria_id = ?
				AND ka.storno = 'f'
			GROUP BY v.id
			ORDER BY vnf.nezettseg 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();

    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 = getVideok($kat_id);
    }

    $c->assign('videok', $videok);

    $sql = "SELECT k.nev, k.title, k.description, k.keywords FROM kategoria k WHERE k.storno = 'f' AND k.id = ?";
    $kat_seo = $db->GetRow($sql, $bind);

    switch($tabla){
        case 'vt_video_nezettseg_full':
            $title = "Most viewed videos - " . $kat_seo['nev'];
            $keywords = "Most viewed videos, " . strtolower($kat_seo['nev']);
            $description = "Most viewed videos in the " . $kat_seo['nev'] . " category. Most viewed videos of the category.";
            break;
        case 'vt_video_nezettseg_havi':
            $title = "Most viewed videos of the month - " . $kat_seo['nev'];
            $keywords = "Most viewed videos of the month, " . strtolower($kat_seo['nev']);
            $description = "Most viewed videos of the month - " . $kat_seo['nev'] . ". The most viewed videos of the month by audience.";
            break;
        case 'vt_video_nezettseg_heti':
            $title = $kat_seo['nev'] . " - The most viewed videos of the week";
            $keywords = strtolower($kat_seo['nev']) . ", most viewed videos of the week";
            $description = $kat_seo['nev'] . " - The most viewed videos of the week. Step by Step videos of the week by audience.";
            break;
        case 'vt_video_nezettseg_napi':
            $title = "Most viewed videos of the day - " . $kat_seo['nev'];
            $keywords = "Most viewed videos of the day, " . strtolower($kat_seo['nev']);
            $description = "Most viewed videos of the day - " . $kat_seo['nev'] . ". The most viewed Step by Step videos of the past 24 hours.";
            break;
        default:
            $title = "Most viewed video - " . $kat_seo['nev'];
            $keywords = "Most viewed video, " . strtolower($kat_seo['nev']);
            $description = "Most viewed video in the " . $kat_seo['nev'] . " category. Most viewed videos of the category.";
            break;
    }

    Registry::get('page')->assign('title', $title);
    Registry::get('page')->assign('description', $description);
    Registry::get('page')->assign('keywords', $keywords);

    return;
}

function getVideosByErtekeles($kat_id, $c, $tabla)
{
    $db = Registry::get('db');

    $bind = array($kat_id);

    if(empty($tabla)){
        $tabe = "vt_video_szavazat_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 */
			WHERE v.storno = 'f'
				AND v.aktiv = 't'
				AND v.kategoria_id = ?
				AND ka.storno = 'f'
			GROUP BY v.id
			ORDER BY vnf.szazalek DESC, ertekeles DESC, vnf.szavazatok 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 = getVideok($kat_id);
    }

    $c->assign('videok', $videok);

    $sql = "SELECT k.nev, k.title, k.description, k.keywords FROM kategoria k WHERE k.storno = 'f' AND k.id = ?";
    $kat_seo = $db->GetRow($sql, $bind);

    switch($tabla){
        case 'vt_video_szavazas_full':
            $title = "Highest rated videos - " . $kat_seo['nev'];
            $keywords = "Highest rated videos, " . strtolower($kat_seo['nev']);
            $description = "Highest rated videos - " . $kat_seo['nev'] . ". The best videos of Nail Tube.com according to the votes by nail artist users.";
            break;
        case 'vt_video_szavazas_havi':
            $title = "The best videos of the month - " . $kat_seo['nev'];
            $keywords = "The best videos of the month, " . strtolower($kat_seo['nev']);
            $description = "The best videos of the month in the " . $kat_seo['nev'] . " category. The stars of the month. Step by Step videos.";
            break;
        case 'vt_video_szavazas_heti':
            $title = $kat_seo['nev'] . " - the BEST videos of the week";
            $keywords = strtolower($kat_seo['nev']) . ", the BEST videos of the week";
            $description = $kat_seo['nev'] . " - the BEST videos of the week. The highest rated Step by Step videos by the nail artist users.";
            break;
        case 'vt_video_szavazas_napi':
            $title = "TOP 24 videos - " . $kat_seo['nev'];
            $keywords = "Top 24 videos, " . strtolower($kat_seo['nev']);
            $description = "TOP 24 videos - " . $kat_seo['nev'] . ". The best videos in the category according to the rates.";
            break;
        default:
            $title = "Legjobbra értékelt videók - " . $kat_seo['nev'];
            $keywords = "legjobbra értékelt videók, " . strtolower($kat_seo['nev']);
            $description = "Legjobbra értékelt videók - " . $kat_seo['nev'] . ". The best videos of Nail Tube.com according to the votes by nail artist users.";
            break;
    }

    Registry::get('page')->assign('title', $title);
    Registry::get('page')->assign('description', $description);
    Registry::get('page')->assign('keywords', $keywords);

    return;
}

function getVideosBySzavazatszam($kat_id, $c, $ido)
{
    $db = Registry::get('db');

    $bind = array($kat_id);

    if(empty($tabla)){
        $tabe = "vt_video_szavazat_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 */
			WHERE v.storno = 'f'
				AND v.aktiv = 't'
				AND v.kategoria_id = ?
				AND szavazatok > 0
				AND ka.storno = 'f'
				".$where."
			GROUP BY v.id
			ORDER BY szavazatok DESC, ertekeles 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 = getVideok($kat_id);
    }

    $c->assign('videok', $videok);

    $sql = "SELECT k.nev, k.title, k.description, k.keywords FROM kategoria k WHERE k.storno = 'f' AND k.id = ?";
    $kat_seo = $db->GetRow($sql, $bind);

    switch($ido){
        case 'full':
            $title = "Top rated videos - " . $kat_seo['nev'];
            $keywords = "Top rated videos, " . strtolower($kat_seo['nev']);
            $description = "Top rated videos in the " . $kat_seo['nev'] . " category. Top videos by rating in the order of rates.";
            break;
        case 'month':
            $title = "Highest rated videos in the month - " . $kat_seo['nev'];
            $keywords = "Highest reted videos in the month, " . strtolower($kat_seo['nev']);
            $description = "Highest rated videos in the month in the " . $kat_seo['nev'] . " category. Top videos in this month in the order of rates.";
            break;
        case 'week':
            $title = $kat_seo['nev'] . " video - the most voted videos in the week";
            $keywords = strtolower($kat_seo['nev']) . " video, the most, voted, videos, in the week";
            $description = $kat_seo['nev'] . " video - the most voted videos in the week. According to the votes of the nail artist users given last week.";
            break;
        case 'day':
            $title = "The most voted in " . $kat_seo['nev'] . " videos";
            $keywords = "The most voted in , " . strtolower($kat_seo['nev']) . " videos";
            $description = "The most voted in - " . $kat_seo['nev'] . " videos. The highest voted Step by Step video of the last 24 hours.";
            break;
        default:
            $title = "Top rated videos - " . $kat_seo['nev'];
            $keywords = "Top rated videos, " . strtolower($kat_seo['nev']);
            $description = "Top rated videos in the " . $kat_seo['nev'] . " category. Top videos by rating in the order of rates.";
            break;
    }

    Registry::get('page')->assign('title', $title);
    Registry::get('page')->assign('description', $description);
    Registry::get('page')->assign('keywords', $keywords);

    return;
}


function getVideosByKedvencszam($kat_id, $c, $tabla)
{
    $db = Registry::get('db');

    $bind = array($kat_id);

    if(empty($tabla)){
        $tabe = "vt_video_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 */
			WHERE v.storno = 'f'
				AND v.aktiv = 't'
				AND v.kategoria_id = ?
				AND ka.storno = 'f'
			GROUP BY v.id
			ORDER BY vnf.kedvenc DESC, ertekeles 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 = getVideok($kat_id);
    }
    $c->assign('videok', $videok);

    $sql = "SELECT k.nev, k.title, k.description, k.keywords FROM kategoria k WHERE k.storno = 'f' AND k.id = ?";
    $kat_seo = $db->GetRow($sql, $bind);

    switch($tabla){
        case 'vt_video_kedvenc_full':
            $title = "Favourite videos - " . $kat_seo['nev'];
            $keywords = "Favourite videos, " . strtolower($kat_seo['nev']);
            $description = "Favourite videos - " . $kat_seo['nev'] . ". The most popular videos by the users of Nail Tube.com.";
            break;
        case 'vt_video_kedvenc_havi':
            $title = $kat_seo['nev'] . " - favourite video of the month";
            $keywords = strtolower($kat_seo['nev']) . ", favourite video of the month";
            $description = $kat_seo['nev'] . " - favourite video of the month. Videos which were placed in to the favourites by the users of Nail Tube.com last month.";
            break;
        case 'vt_video_kedvenc_heti':
            $title = "Favourite videos of the week - " . $kat_seo['nev'];
            $keywords = "Weekly favourite, " . strtolower($kat_seo['nev']) . ", videos";
            $description = "Favourite videos of the week - " . $kat_seo['nev'] . " videos. Videos which were placed in to the favourites by the users of Nail Tube.com last week.";
            break;
        case 'vt_video_kedvenc_napi':
            $title = "Favourite videos of today - " . $kat_seo['nev'];
            $keywords = "Favourite videos, today, " . strtolower($kat_seo['nev']);
            $description = "Favourite videos of today - " . $kat_seo['nev'] . ". Step by Step in the order of the daily rates.";
            break;
        default:
            $title = "Favourite videos - " . $kat_seo['nev'];
            $keywords = "Favourite videos, " . strtolower($kat_seo['nev']);
            $description = "Favourite videos - " . $kat_seo['nev'] . ". Most popular Step by Step videos by the nail artist users of Nail Tube.com.";
            break;
    }

    Registry::get('page')->assign('title', $title);
    Registry::get('page')->assign('description', $description);
    Registry::get('page')->assign('keywords', $keywords);

    return;
}
function getVideok($kat_id)
{
    $db = Registry::get('db');

    $bind = array($kat_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 kategoria ka ON ka.id = v.kategoria_id
            LEFT JOIN video_nezettseg vn ON vn.video_id = v.id
            LEFT JOIN vt_video_szavazas_full vtvszf ON vtvszf.video_id = v.id
            WHERE v.storno = 'f'
                AND v.aktiv = 't'
                AND v.kategoria_id = ?
                AND ka.storno = 'f'
            GROUP BY v.id
            ORDER BY v.sorrend, v.datum DESC";
    $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, 4);
        $videok[$key]['ertekeles'] = intval($val['ertekeles']);
        $videok[$key]['datum'] = str_replace('-','.',$val['datum']);
    }

    return $videok;
}

?>

Zerion Mini Shell 1.0