function www_hits_search()
{
    $users = new usersMenus();
    SEND_CORP_LICENSE();
    $page = CurrentPageName();
    $tpl = new templates();
    $t = time();
    $boot = new boostrap_form();
    $search = string_to_flexquery("search-hits");
    $xtime = $_GET["xtime"];
    $hourtable = $tablemain = "youtubeday_" . date("Ymd", $_GET["xtime"]);
    $q = new mysql_squid_builder();
    $sql = "SELECT * FROM {$hourtable} WHERE youtubeid='{$_GET["youtubeid"]}' AND `{$_GET["filterBy"]}`='{$_GET["value"]}' ORDER BY `hour`";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        senderror($q->mysql_error);
    }
    $youtube = new YoutubeStats();
    $videotitle = $youtube->youtube_title($_GET["youtubeid"]);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $youtubeid = $ligne["youtubeid"];
        $hits = FormatNumber($ligne["hits"]);
        $urljsSIT = "Loadjs('miniadm.webstats.youtubeid.php?youtubeid={$youtubeid}')";
        $link = $boot->trswitch($urljsSIT);
        $urljsHour = "Loadjs('miniadm.webstats.ByHourYoutube.php?youtubeid={$youtubeid}&hour={$ligne["hour"]}&xtime={$_GET["xtime"]}')";
        $linkHour = $boot->trswitch($urljsHour);
        $tr[] = "\n\t\t<tr>\n\t\t<td {$linkHour}><i class='icon-globe'></i>&nbsp;{$ligne["hour"]}h</td>\n\t\t<td {$link}><i class='icon-globe'></i>&nbsp;{$videotitle}</td>\n\t\t<td nowrap><i class='icon-info-sign'></i>&nbsp;{$hits}</td>\n\t\t</tr>";
    }
    echo $tpl->_ENGINE_parse_body("\n\t\t\t<table class='table table-bordered table-hover'>\n\t\n\t\t\t<thead>\n\t\t\t<tr>\n\t\t\t<th>{hour}</th>\n\t\t\t<th>{video}</th>\n\t\t\t<th>{hits}</th>\n\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>\n\t\t\t") . @implode("", $tr) . "</tbody></table>";
}
function graph2()
{
    $tpl = new templates();
    $unknown = $tpl->_ENGINE_parse_body("{unknown}");
    $q = new mysql_squid_builder();
    $tpl = new templates();
    $youtube = new YoutubeStats();
    $sql = "SELECT SUM(hits) as hits,youtubeid FROM `youtube_all` GROUP BY\n\tyoutubeid ORDER BY hits DESC LIMIT 0,15";
    $results = $q->QUERY_SQL($sql);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $size = $ligne["hits"];
        $title = $youtube->youtube_title($ligne["youtubeid"]);
        if (strlen($title) > 20) {
            $title = substr($title, 0, 17) . "...";
        }
        $PieData[$title] = $size;
    }
    if (!$q->ok) {
        $tpl->javascript_senderror($q->mysql_error, $_GET["container"]);
    }
    $tpl = new templates();
    $highcharts = new highcharts();
    $highcharts->container = $_GET["container"];
    $highcharts->PieDatas = $PieData;
    $highcharts->ChartType = "pie";
    $highcharts->PiePlotTitle = "{videos}";
    $highcharts->Title = $tpl->_ENGINE_parse_body("{top_videos}/{hits}");
    echo $highcharts->BuildChart();
}
function generate_graph3()
{
    $q = new mysql_squid_builder();
    $page = CurrentPageName();
    $tpl = new templates();
    $t = $_GET["t"];
    $ff = time();
    $graph1 = null;
    $graph2 = null;
    $xtime = $_GET["xtime"];
    $tablename = "youtubeday_" . date("Ymd", $xtime);
    $youtube = new YoutubeStats();
    $sql = "SELECT SUM(hits) as hits,youtubeid,`hour` FROM `{$tablename}` GROUP BY youtubeid,`hour`\n\tHAVING `hour`='{$_GET["hour"]}'\n\tORDER BY hits DESC LIMIT 0,15";
    $unknown = $tpl->_ENGINE_parse_body("{unknown}");
    $c = 0;
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
    }
    if (mysql_num_rows($results) > 0) {
        while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
            $PieData[substr($youtube->youtube_title($ligne["youtubeid"]), 0, 20)] = $ligne["hits"];
            $c++;
        }
        $highcharts = new highcharts();
        $highcharts->container = $_GET["container"];
        $highcharts->PieDatas = $PieData;
        $highcharts->ChartType = "pie";
        $highcharts->PiePlotTitle = "{hits}";
        $highcharts->Title = $tpl->_ENGINE_parse_body("Youtube: {top_videos}/{hits}");
        echo $highcharts->BuildChart();
    }
}