public function admin_index() { $this->set('title', __('Dashboard')); //$this->set('description', __('Manage Quiz')); $practiceTests = $this->PracticeTest->find('all', array('order' => array('PracticeTest.created' => 'DESC'), 'limit' => 20)); $this->set('practiceTests', $practiceTests); $FavouritePracticeTests = $this->PracticeTest->find('all', array('order' => array('PracticeTest.avg' => 'DESC'), 'limit' => 10)); $this->set('FavouritePracticeTests', $FavouritePracticeTests); $users = $this->User->find('all', array('order' => array('User.created' => 'DESC'), 'limit' => 10)); $this->set('users', $users); //google analytics if (Configure::read('GA.email') != '' && Configure::read('GA.password') != '') { try { // construct the class $oAnalytics = new analytics(Configure::read('GA.email'), Configure::read('GA.password')); // set it up to use caching $oAnalytics->useCache(); //$oAnalytics->setProfileByName(Configure::read('GA.domain')); $oAnalytics->setProfileById(Configure::read('GA.profile_id')); // set the date range //$oAnalytics->setMonth(date('n'), date('Y')); $oAnalytics->setDateRange(date('Y-m-d', strtotime('-1 week')), date('Y-m-d')); //echo '<pre>'; // print out visitors for given period //print_r($oAnalytics->getVisitors()); // print out pageviews for given period //print_r($oAnalytics->getPageviews()); // use dimensions and metrics for output // see: http://code.google.com/intl/nl/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html // print_r($oAnalytics->getData(array( 'dimensions' => 'ga:keyword', // 'metrics' => 'ga:visits', // 'sort' => 'ga:keyword'))); //print_r($oAnalytics->getData(array('dimensions' => 'ga:visitorType','metrics' => 'ga:newVisits'))); $visits = $oAnalytics->getVisitors(); $views = $oAnalytics->getPageviews(); /* build tables */ if (count($visits)) { $visits = $this->array_filter_recursive($visits); $views = $this->array_filter_recursive($views); foreach ($visits as $day => $visit) { $flot_datas_visits[] = '[' . $day . ',' . $visit . ']'; $flot_datas_views[] = '[' . $day . ',' . $views[$day] . ']'; } $flot_data_visits = '[' . implode(',', $flot_datas_visits) . ']'; $flot_data_views = '[' . implode(',', $flot_datas_views) . ']'; } $this->set(compact('flot_data_visits', 'flot_data_views')); } catch (Exception $e) { //echo 'Caught exception: ' . $e->getMessage(); } } }
include "../" . MODS_DIRECTORY . "/charts/FusionCharts_Gen.php"; include "../" . USER_DIRECTORY . "/header.php"; $js = "<script language=\"javascript\" src=\"{$website}/" . JS_DIRECTORY . "/FusionCharts.js\"></script>"; subheader(_("Statistics"), null, $js); if ($sesslife == true) { if ($is_admin == 1) { echo "<div class=\"page-header\"><h1>" . _("Statistics") . "</h1></div>"; echo "<h6>" . _("Options") . " : <a href=\"{$website}/" . ADMIN_DIRECTORY . "/settings#/analytics\">" . _("Analytics Settings") . "</a></h6><br/>"; echo "<ul class=\"breadcrumb\">\n\t\t<li><a href=\"{$website}/" . ADMIN_DIRECTORY . "/settings\">" . _("Home") . "</a> <span class=\"divider\">/</span></li>\n\t\t<li class=\"active\">" . _("Statistics") . "</li>\n\t\t</ul>"; if (!empty($_setting['google_id']) && !empty($_setting['google_password']) && !empty($_setting['site_id'])) { echo "<div class=\"alert\">" . _("Google ID") . " : <strong>{$_setting['google_id']}</strong> " . _("Site ID") . " : <strong>{$_setting['site_id']}</strong></div>"; $analytics = new analytics($_setting['google_id'], $_setting['google_password']); $analytics->setProfileById("ga:" . $_setting['site_id']); $analytics->setMonth(date("n"), date("Y")); $month = date("M"); $visitors = $analytics->getVisitors(); $total = count($visitors); $basic = 0; $count = "01"; while ($count < $total + 1) { $arrData[$basic][0] = $count; $arrData[$basic][1] = $visitors[$count]; $count++; $basic++; if ($count < 10) { $count = "0" . $count; } } $FC = new FusionCharts("Column3D", "800", "300"); /* set Relative Path of chart swf file.
<?php // session_start for caching session_start(); require 'analytics.class.php'; try { // construct the class $oAnalytics = new analytics('[username]', '[password]'); // set it up to use caching $oAnalytics->useCache(); $oAnalytics->setProfileByName('[Google analytics accountname]'); // or $oAnalytics->setProfileById('ga:123456'); // set the date range $oAnalytics->setMonth(date('n'), date('Y')); // or $oAnalytics->setDateRange('YYYY-MM-DD', 'YYYY-MM-DD'); echo '<pre>'; // print out visitors for given period print_r($oAnalytics->getVisitors()); // print out pageviews for given period print_r($oAnalytics->getPageviews()); // use dimensions and metrics for output // see: http://code.google.com/intl/nl/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html print_r($oAnalytics->getData(array('dimensions' => 'ga:keyword', 'metrics' => 'ga:visits', 'sort' => 'ga:keyword'))); } catch (Exception $e) { echo 'Caught exception: ' . $e->getMessage(); }
</select> <label for="month">Month</label> <select name="month" id="month"> <?php $aMonth = range(1, date('n')); foreach($aMonth as $iMonth){ echo '<option ' . ($iMonth == $iSelectedMonth ? 'selected="selected" ' : '') . 'value="' . $iMonth . '">' . date('F', mktime(0, 0, 0, $iMonth, 1, date('Y'))) . '</option>'; } ?> </select> <input type="submit" id="submit" value="Submit"> <a href="./">Log out</a> </form> <h2>Visitors:</h2> <?php graph($oAnalytics->getVisitors()); ?> <h2>Pageviews:</h2> <?php graph($oAnalytics->getPageviews()); ?> <h2>Visits per Hour:</h2> <?php graph($oAnalytics->getVisitsPerHour()); ?> <h2>Browsers:</h2> <?php graph($oAnalytics->getBrowsers()); ?> <h2>Referrers:</h2> <?php graph($oAnalytics->getReferrers()); ?> <h2>Search words:</h2> <?php graph($oAnalytics->getSearchWords()); ?>