%PDF- %PDF-
Mini Shell

Mini Shell

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

<?php

require_once 'config/config.php';

$p['title'] = 'Nails TV - Nail Art videos';
$p['desc'] = 'Nail Art video channels, Nail Art masterpieces, Top Nail Artists, Step-by-Step tutorials and more.';
$p['keywords'] = 'műköröm videó, műkörmös videó, step by step, videók, műköröm készítés, körömdíszítés';
$p['pagename'] = 'Home';
$p['active'] = "főoldal";

$page = new Page(Registry::get('site'), false, $p);
Registry::set('page', $page);
$page->assign('content', content());
$page->display('page.tpl.html');

////////////////////////////////////////////////////////////////////////////////

function content()
{
    $c = new Content();

    Page::seoFromDb(1);

    $c->assign('kiemelt', kiemelt_videok($c));
    $c->assign('video_ajanlott', ajalott_videok());
    $c->assign('video_most_nezik', mostnezik());
    $c->assign('video_legujabb', legujabb());

    $c->assign('video_heti_legtobbszor', heti_legtobbszor());
    $c->assign('video_heti_legjobb', video_heti_legjobb());


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



function kiemelt_videok($c)
{
    $db = Registry::get('db');

    $sql = "SELECT v.id, v.cim, v.datum, v.hossz,v.osszes_nezettseg as nezettseg, /* COUNT(vn.id) as nezettseg, */ ka.url, ka.url as kat_url, ka.nev as kat, vtvszf.szazalek as ertekeles, v.file, v.file_mp4, k.file as kep, 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.kiemelt = 't'
				AND ka.storno ='f'
				AND k.file IS NOT NULL
			GROUP BY v.id 
			ORDER BY v.sorrend
			LIMIT 0,3";

    $kiem = $db->GetArray($sql);


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

    foreach($kiem as $key=>$val){
        $kiem[$key]['url'] = $val['url'] . '/' . String::fancyurl($val['cim']) . '-' . $val['id'];
        $kiem[$key]['hossz'] = substr($val['hossz'], 0, 5);
        $kiem[$key]['ertekeles'] = intval($val['ertekeles']);

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

    }

    return $kiem;
}

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

    $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 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.ajanlott = 't'
				AND ka.storno ='f'
				AND k.file IS NOT NULL
			GROUP BY v.id 
			ORDER BY v.sorrend
			LIMIT 0,4";

    $ajanlott = $db->GetArray($sql);

    foreach($ajanlott as $key=>$val){
        $ajanlott[$key]['url'] = $val['url'] . '/' . String::fancyurl($val['cim']) . '-' . $val['id'];
        $ajanlott[$key]['hossz'] = substr($val['hossz'], 0, 5);
        $ajanlott[$key]['ertekeles'] = intval($val['ertekeles']);
    }

    return $ajanlott;
}

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

    $sql = "SELECT DISTINCT video_id FROM most_nezik ORDER BY id DESC LIMIT 0,4";
    $videok = $db->GetCol($sql);
    $videok = implode (',', $videok);

    $sql = "SELECT v.id, v.cim, v.datum, v.hossz, 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 vt_video_szavazas_full vtvszf ON vtvszf.video_id = v.id
			WHERE v.id IN (".$videok.")
				AND v.storno = 'f'
				AND v.aktiv = 't'
				AND ka.storno ='f'
			ORDER BY FIELD(v.id, ".$videok.")";

    $most = $db->GetArray($sql);

    foreach($most as $key=>$val){
        $most[$key]['url'] = $val['url'] . '/' . String::fancyurl($val['cim']) . '-' . $val['id'];
        $most[$key]['hossz'] = substr($val['hossz'], 0, 5);

        $most[$key]['nezettseg'] = getNezettseg($val['id']);
        $most[$key]['ertekeles'] = intval($val['ertekeles']);
    }

    return $most;
}

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

    $bind = array($id);

    $sql = "SELECT COUNT(vn.id) as nezettseg
			FROM video_nezettseg vn
			WHERE vn.video_id = ?";
    $row = $db->GetRow($sql, $bind);

    return $row['nezettseg'];
}

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

    $sql = "SELECT v.id, v.cim, v.datum, v.hossz, ka.url, k.file, k.id as kep_id
			FROM video v 
			" . $db->joinDefPic('video', 'v') . "
			LEFT JOIN kategoria ka ON ka.id = v.kategoria_id
			WHERE v.storno = 'f'
				AND v.aktiv = 't'
				AND ka.storno ='f'
			GROUP BY v.id 
			ORDER BY v.datum DESC
			LIMIT 0,4";

    //print $sql; die;

    $legujabb = $db->GetArray($sql);

    foreach($legujabb as $key=>$val){
        $bind = array($val['id']);
        $sql = "SELECT COUNT(id) as nezettseg
				FROM video_nezettseg
				WHERE video_id = ?";
        $row = $db->GetRow($sql, $bind);

        $legujabb[$key]['nezettseg'] = $row['nezettseg'];

        $sql = "SELECT szazalek as ertekeles
				FROM vt_video_szavazas_full
				WHERE video_id = ?";
        $row = $db->GetRow($sql, $bind);

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

    return $legujabb;
}

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

    /*
        $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 vt_video_nezettseg_heti vt
                LEFT JOIN video v ON v.id = vt.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 ka.storno ='f'
                GROUP BY vt.video_id
                ORDER BY vt.nezettseg DESC, v.datum DESC
                LIMIT 0,5";
    */

    /*
    $sql = "SELECT v.id, v.cim, v.datum, v.hossz, vt.nezettseg as nezettseg, ka.url, vtvszf.szazalek as ertekeles, k.file, k.id as kep_id
			FROM vt_video_nezettseg_heti vt
			LEFT JOIN video v ON v.id = vt.video_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
			WHERE v.storno = 'f'
				AND v.aktiv = 't'
				AND ka.storno ='f'
			GROUP BY vt.video_id 
			ORDER BY vt.nezettseg DESC, v.datum DESC
			LIMIT 0,4";
    */
    $sql = "SELECT v.id, v.cim, v.datum, v.hossz,v.osszes_nezettseg 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 vt_video_szavazas_full vtvszf ON vtvszf.video_id = v.id
            WHERE v.storno = 'f'
                AND v.aktiv = 't'
                AND ka.storno = 'f'
            GROUP BY v.id
            ORDER BY v.heti_nezettseg DESC,v.datum DESC
            LIMIT 0,4";        

    $heti_legtobbszor = $db->GetArray($sql);

    //print $sql; die;

    foreach($heti_legtobbszor as $key=>$val){
        $bind = array($val['id']);
        $sql = "SELECT COUNT(id) as nezettseg
				FROM video_nezettseg
				WHERE video_id = ?";

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

        $heti_legtobbszor[$key]['nezettseg'] = $row['nezettseg'];
        $heti_legtobbszor[$key]['url'] = $val['url'] . '/' . String::fancyurl($val['cim']) . '-' . $val['id'];
        $heti_legtobbszor[$key]['hossz'] = substr($val['hossz'], 0, 5);
        $heti_legtobbszor[$key]['ertekeles'] = intval($val['ertekeles']);
    }

    return $heti_legtobbszor;
}

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

    /*
    $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  vt_video_szavazas_heti vt
            LEFT JOIN video v ON v.id = vt.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 ka.storno ='f'
            GROUP BY vt.video_id
            ORDER BY vt.szazalek DESC, v.datum DESC
            LIMIT 0,5";
    */
    $sql = "SELECT v.id, v.cim, v.datum, v.hossz, ka.url, k.file, k.id as kep_id
			FROM  vt_video_szavazas_heti vt
			LEFT JOIN video v ON v.id = vt.video_id
			" . $db->joinDefPic('video', 'v') . "
			LEFT JOIN kategoria ka ON ka.id = v.kategoria_id
			WHERE v.storno = 'f'
				AND v.aktiv = 't'
				AND ka.storno ='f'
			GROUP BY vt.video_id 
			ORDER BY vt.szazalek DESC, v.datum DESC
			LIMIT 0,4";

    $legjobb = $db->GetArray($sql);

    foreach($legjobb as $key=>$val){
        $bind = array($val['id']);
        $sql = "SELECT COUNT(id) as nezettseg
				FROM video_nezettseg
				WHERE video_id = ?";
        $row = $db->GetRow($sql, $bind);

        $legjobb[$key]['nezettseg'] = $row['nezettseg'];

        $sql = "SELECT szazalek as ertekeles
				FROM vt_video_szavazas_full
				WHERE video_id = ?";
        $row = $db->GetRow($sql, $bind);

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

    return $legjobb;
}

?>

Zerion Mini Shell 1.0