static function find($search_id)
 {
     $found_site = '';
     $sites = Sites::getAll();
     foreach ($sites as $site) {
         // $site_id = $site->getId();
         if ($id === $search_id) {
             $found_site = $site;
             print_r($found_site);
             return $found_site;
         }
     }
 }
Exemplo n.º 2
0
    //setting up connection to our database
    $DB = new PDO($server, $username, $password);
    //Throw an exception when an error is encountered in the query
    $DB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $DB->exec("SET NAMES 'utf8'");
} catch (Exception $e) {
    echo "Could not connect to the database";
    exit;
}
$app = new Silex\Application();
$app["debug"] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../../views'));
use Symfony\Component\HttpFoundation\Request;
Request::enableHttpMethodParameterOverride();
/**
 * Routing to twig templete views
 */
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig', array('sites' => Sites::getAll()));
});
$app->get('/site/{id}', function ($id) use($app) {
    $sites = Sites::getAll();
    function name($sites, $id)
    {
        $id = $id - 1;
        return $sites[$id];
    }
    $sites = name($sites, $id);
    return $app['twig']->render('site.html.twig', array('sites' => $sites, 'analytics' => ReturnedAnalytics::getAll($id)));
});
return $app;
Exemplo n.º 3
0
    // Read the generated client_secrets.p12 key.
    $cred = new Google_Auth_AssertionCredentials($service_account_email, array(Google_Service_Analytics::ANALYTICS_READONLY), $key);
    $client->setAssertionCredentials($cred);
    if ($client->getAuth()->isAccessTokenExpired()) {
        $client->getAuth()->refreshTokenWithAssertion($cred);
    }
    return $analytics;
}
/**
 * Get Analytics API instance
 */
$analytics = getService($google_account['email'], $google_account['key']);
/**
 * Gets objects from the site table
 */
$site_details = Sites::getAll();
$site_details_length = sizeof($site_details);
if ($site_details_length <= 0) {
    trigger_error('Size of site_details_length must be greater than zero', E_USER_NOTICE);
    error_log($today . "The sites tables has return zero sites from the database \n", 3, __DIR__ . "/../../log/error.log");
    exit;
}
echo "*******************" . "\n";
echo "* total sites : " . $site_details_length . " *" . "\n";
echo "*******************" . "\n";
/**
 * Query the Analytics data.
 * date, source, medium,channel_grouping, device_category, landing_page_path, sessions,
 * transactions, transaction_revenue, page_views, bounces, session_duration, hits, total_events,
 * unique_events, users, entrances, exits
 */