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 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> {$ligne["hour"]}h</td>\n\t\t<td {$link}><i class='icon-globe'></i> {$videotitle}</td>\n\t\t<td nowrap><i class='icon-info-sign'></i> {$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 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(); } }
function Repair_youtube_objects() { include_once dirname(__FILE__) . "/ressources/class.squid.youtube.inc"; $q = new mysql_squid_builder(); $sql = "SELECT youtubeid FROM youtube_objects WHERE LENGTH(title)<5 LIMIT 0,100"; $results = $q->QUERY_SQL($sql); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { echo "{$ligne["youtubeid"]}\n"; $ytbe = new YoutubeStats(); $ytbe->youtube_infos($ligne["youtubeid"], true); } }
function youtube_all_from_hourtable($tablename) { $q = new mysql_squid_builder(); $sql = "SELECT SUM(hits) as hits,zDate,uid,youtubeid,MAC \n\tFROM `{$tablename}` \n\tGROUP BY zDate,uid,youtubeid,MAC"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { if ($GLOBALS["VERBOSE"]) { echo "############# ERROR #########\n{$q->mysql_error}\\Line:" . __LINE__ . "\n#############\n"; } return; } if (mysql_num_rows($results) == 0) { if ($GLOBALS["VERBOSE"]) { echo "No results...\n"; } return true; } $prefix = "INSERT IGNORE INTO `youtube_all` (zmd5,hits,zDate,uid,MAC,youtubeid,category) VALUES "; $youtube = new YoutubeStats(); if ($GLOBALS["VERBOSE"]) { echo mysql_num_rows($results) . " results...\n"; } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $md5 = md5(serialize($ligne)); $ligne["uid"] = mysql_escape_string2($ligne["uid"]); $category = mysql_escape_string2($youtube->youtube_category($ligne["youtubeid"])); $f[] = "('{$md5}','{$ligne["hits"]}','{$ligne["zDate"]}','{$ligne["uid"]}','{$ligne["MAC"]}','{$ligne["youtubeid"]}','{$category}')"; if (count($f) > 500) { $q->QUERY_SQL($prefix . @implode(",", $f)); $f = array(); if (!$q->ok) { return false; } } } if (count($f) > 0) { $q->QUERY_SQL($prefix . @implode(",", $f)); $f = array(); if (!$q->ok) { return false; } } return true; }