%PDF- %PDF-
Mini Shell

Mini Shell

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

<?php

require_once 'config/config.php';

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

if(!empty($uri[1])) {
    $u = String::parseUrl($uri[1]);
    $_POST['k'] = $u['url'];
    if(!empty($u['page'])) $_GET['page'] = $_REQUEST['page'] = $u['page'];
}

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

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

function content()
{
    $db = Registry::get('db');
    $c = new Content();

    if(!empty($_POST['k'])) {
        $k = htmlspecialchars(stripslashes($_POST['k']));
        $k = urldecode(substr($k, 0, 100));

        $_SESSION['k'] = $k;
    }
    elseif($_POST && empty($_POST['k'])) {
        $_SESSION['k'] = '';
    }

    if(empty($_SESSION['k'])) return $c->fetch('kereses.tpl.html');

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

    $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 vt_video_szavazas_full vtvszf ON vtvszf.video_id = v.id
			LEFT JOIN termekek t ON t.video_id = v.id AND t.tipus = 'video'
			/*LEFT JOIN video_nezettseg vn ON vn.video_id = v.id*/
            WHERE (v.keres LIKE '%" . $_SESSION['k'] . "%'
				OR v.cim LIKE '%" . $_SESSION['k'] . "%'
				OR t.nev LIKE '%" . $_SESSION['k'] . "%')
                AND v.storno = 'f'
                AND v.aktiv = 't'
				AND ka.storno = 'f'
			GROUP BY v.id	
            ORDER BY v.datum DESC";

           // die($sql);

    $pager = new Pager;
    $limit = 16;
    $r = $db->PageExecute($sql, $limit, $pager->current);

    $pager->setup($r->LastPageNo(), $r->RecordCount(), $limit, '', true);
    $c->assign('pager', $pager->show('pager.tpl.html'));

    $talalat = $r->GetArray();

    $talalat = Video::getViews($talalat);

    foreach($talalat as $key => $val) {
        //$r_url = explode('.', $val['url']);
        //$talalat[$key]['url'] = $r_url[0] . '/' . $val['id'] . '-' . $val['url'];

        //$talalat[$key]['szoveg'] = highlight($val['szoveg'], $_SESSION['k']);
        $talalat[$key]['url'] = $val['url'] . '/' . String::fancyurl($val['cim']) . '-' . $val['id'];
        $talalat[$key]['hossz'] = substr($val['hossz'], 0, 5);
        $talalat[$key]['ertekeles'] = intval($val['ertekeles']);
        $talalat[$key]['datum'] = str_replace('-','.',$val['datum']);
    }

    $c->assign('talalat', $talalat);
    $c->assign('kifejezes', $_SESSION['k']);

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

function highlight($s, $k, $len = 200)
{
    $pos = mb_strpos(mb_strtolower($s, 'UTF-8'), mb_strtolower($k, 'UTF-8'), 0, 'UTF-8');

    $pos -= ceil($len / 3);

    $start = '';

    ($pos < 1) ? $pos = 0 : $start = '...';

    ($pos+$len > mb_strlen($s, 'UTF-8')) ? $end = '' : $end = '...';

    $str = mb_substr($s, $pos, $len, 'UTF-8');

    $str = str_ireplace($k, '<strong>'.$k.'</strong>', $str);

    return $start.$str.$end;
}

/*
function k($s, $k)
{
    $pos = mb_strpos(strtolower($s), strtolower($k));
    $len = mb_strlen($s);

    $pos -= 30;

    if($pos < 0) {
        $pos = 0;
    }

    $newstring = breakStr($s, $pos, 200);

    return str_ireplace($k, '<strong>'.$k.'</strong>', $newstring);
}

function breakStr($s, $pos, $len, $spaceOnly = true)
{
    if(mb_strlen($s, 'UTF-8') > $len) {
        if($spaceOnly) {
            while($s[$pos] != ' ') {
                $pos++;
            }
            while($s[$len] != ' ') {
                $len++;
            }
        }
        echo $pos . ' - ' . $len . '<br />';
        $str = mb_substr($s, $pos, $len, 'UTF-8');
    }
    else {
        $str = $s;
    }

    return $str;
}
*/

?>

Zerion Mini Shell 1.0