public function audienceAccueilAction() { $em = $this->getDoctrine()->getManager(); $rep = $em->getRepository('APPCoreBundle:Abonne'); $inscr = $rep->findBy(array('softDelete' => 0), array(), null, null); $nbInscr = count($inscr); $desinscr = $rep->findBy(array('softDelete' => 1), array(), null, null); $nbDesinscr = count($desinscr); $generalite = $this->general(); /*analytics*/ $rep2 = $em->getRepository('APPAdminBundle:Visite'); /*graphique 1*/ $jour = new \datetime(); $fix = new \Datetime(); $date = $jour->format('D'); $jour2 = $jour->modify('-1 day'); $date2 = $jour2->format('D'); $jour3 = $jour->modify('-1 days'); $date3 = $jour3->format('D'); $jour4 = $jour->modify('-1 days'); $date4 = $jour4->format('D'); $jour5 = $jour->modify('-1 days'); $date5 = $jour5->format('D'); $jour6 = $jour->modify('-1 days'); $date6 = $jour6->format('D'); $jour7 = $jour->modify('-1 days'); $date7 = $jour7->format('D'); $joursDeLaSemaine = array('Mon' => 'Lun', 'Tue' => 'Mar', 'Wed' => 'Mer', 'Thu' => 'Jeu', 'Fri' => 'Ven', 'Sat' => 'Sam', 'Sun' => 'Dim'); $chiffres = array(array('new' => 0, 'ret' => 0), array('new' => 0, 'ret' => 0), array('new' => 0, 'ret' => 0), array('new' => 0, 'ret' => 0), array('new' => 0, 'ret' => 0), array('new' => 0, 'ret' => 0), array('new' => 0, 'ret' => 0)); $visites = $rep2->findAll(); $totalSemaine = 0; $totalVisitesSemaine = 0; foreach ($visites as $analytics) { $newDate = new \datetime($analytics->getDateAjout()->format('Y-m-d')); $newFix = $newDate->format('Y-m-d'); $diff = $fix->diff($newDate); $count = $diff->format('%D'); //die((int)$count.' = '.$fix->format('Y-m-d').' et '.$newDate->format('Y-m-d')); $nb = (int) $count; if ($nb >= 0 && $nb <= 6) { $compte = count($rep2->findByIp($analytics->getIp())); if ($compte == 1) { $totalVisitesSemaine += 1; $chiffres[$nb]['new'] += 1; } else { $totalVisitesSemaine += 1; if ($analytics->getNewSession() == 1) { $totalSemaine += 1; $chiffres[$nb]['ret'] += 1; } } } } $series = array(array("name" => "Nouveau visiteur", "data" => array($chiffres[6]['new'], $chiffres[5]['new'], $chiffres[4]['new'], $chiffres[3]['new'], $chiffres[2]['new'], $chiffres[1]['new'], $chiffres[0]['new'])), array("name" => "Visiteur revenant", "data" => array($chiffres[6]['ret'], $chiffres[5]['ret'], $chiffres[4]['ret'], $chiffres[3]['ret'], $chiffres[2]['ret'], $chiffres[1]['ret'], $chiffres[0]['ret']))); $categories = array($joursDeLaSemaine[$date7], $joursDeLaSemaine[$date6], $joursDeLaSemaine[$date5], $joursDeLaSemaine[$date4], $joursDeLaSemaine[$date3], $joursDeLaSemaine[$date2], $joursDeLaSemaine[$date]); $ob = new Highchart(); $ob->chart->renderTo('linechart'); // The #id of the div where to render the chart $ob->title->text('Visites des 7 derniers jours'); $ob->xAxis->categories($categories); $ob->xAxis->title(array('text' => "Jours")); $ob->yAxis->title(array('text' => "Visites")); $ob->series($series); /*graphique 2*/ $date = new \datetime(); $mois = $date->format('m'); $annee = $date->format('y'); $jour = $date->format('d'); $visitesan = $rep2->findBy(array(), array('dateAjout' => 'desc'), null, null); $cpt = 1; $cptMois = $mois; $cptAnnee = $annee; $cptJour = $jour; $moisArray = array('Jan', 'Fev', 'Mar', 'Avr', 'Mai', 'Jui', 'Jul', 'Aou', 'Sep', 'Oct', 'Nov', 'Dec'); $params = array(); while ($cpt <= 12) { $params[$cpt - 1] = array('mois' => $moisArray[$mois - 1], 'moz' => 0, 'chr' => 0, 'div' => 0); if ($mois + 1 == 13) { $mois = 1; } else { $mois++; } $cpt++; } $totalAnnee = 0; $totalVisitesAnnee = 0; foreach ($visitesan as $analytics) { $newDate = $analytics->getDateAjout(); $newMois = $newDate->format('m'); $newAnnee = $newDate->format('y'); if ($cptAnnee - $newAnnee <= 1) { $offset = $newMois - $cptMois; if ($offset < 0) { $offset = 12 + $offset; } $preSplit = explode("0)", $analytics->getNavigateur()); if (!empty($preSplit[1])) { $morceaux = explode("/", $preSplit[1]); if ($morceaux[0] == ' Gecko') { $totalVisitesAnnee += 1; if ($analytics->getNewSession() == 1) { $totalAnnee += 1; $params[$offset]['moz'] += 1; } } else { if ($morceaux[0] == ' like Gecko') { $totalVisitesAnnee += 1; if ($analytics->getNewSession() == 1) { $totalAnnee += 1; $params[$offset]['div'] += 1; } } } } else { $totalVisitesAnnee += 1; if ($analytics->getNewSession() == 1) { $totalAnnee += 1; $params[$offset]['chr'] += 1; } } } } $series2 = array(array("name" => "Mozilla", "data" => array($params[1]['moz'], $params[2]['moz'], $params[3]['moz'], $params[4]['moz'], $params[5]['moz'], $params[6]['moz'], $params[7]['moz'], $params[8]['moz'], $params[9]['moz'], $params[10]['moz'], $params[11]['moz'], $params[0]['moz'])), array("name" => "Chrome", "data" => array($params[1]['chr'], $params[2]['chr'], $params[3]['chr'], $params[4]['chr'], $params[5]['chr'], $params[6]['chr'], $params[7]['chr'], $params[8]['chr'], $params[9]['chr'], $params[10]['chr'], $params[11]['chr'], $params[0]['chr'])), array("name" => "Autres", "data" => array($params[1]['div'], $params[2]['div'], $params[3]['div'], $params[4]['div'], $params[5]['div'], $params[6]['div'], $params[7]['div'], $params[8]['div'], $params[9]['div'], $params[10]['div'], $params[11]['div'], $params[0]['div']))); $categories2 = array($params[1]['mois'], $params[2]['mois'], $params[3]['mois'], $params[4]['mois'], $params[5]['mois'], $params[6]['mois'], $params[7]['mois'], $params[8]['mois'], $params[9]['mois'], $params[10]['mois'], $params[11]['mois'], $params[0]['mois']); $ob2 = new Highchart(); $ob2->chart->renderTo('linechart2'); // The #id of the div where to render the chart $ob2->title->text('Visites de l\'année entière'); $ob2->xAxis->categories($categories2); $ob2->xAxis->title(array('text' => "Mois")); $ob2->yAxis->title(array('text' => "Visites par navigateur")); $ob2->series($series2); /*fin de*/ return $this->render('APPAdminBundle:pages:audience.html.twig', array('general' => $generalite, 'inscr' => $inscr, 'desinscr' => $desinscr, 'nbInscr' => $nbInscr, 'nbDesinscr' => $nbDesinscr, 'chart' => $ob, 'chart2' => $ob2, 'totalSemaine' => $totalSemaine, 'totalAnnee' => $totalAnnee, 'totalVisitesSemaine' => $totalVisitesSemaine, 'totalVisitesAnnee' => $totalVisitesAnnee)); }
// echo end(); $t = explode('.', $_FILES['image']['name']); $t = end($t); $file_ext = strtolower($t); $expensions = array("jpg", "jpeg", "png", "jpe"); if (in_array($file_ext, $expensions) === false) { $errors[] = "extension not allowed, please choose a JPG file."; } if ($file_size > 2097152) { $errors[] = 'File size must be excately 2 MB'; } if (empty($errors) == true) { move_uploaded_file($file_tmp, "images/store_images/" . $productCount . ".jpg"); echo "Success"; } else { print_r($errors); } } date_default_timezone_set('Asia/Calcutta'); $datetime = new datetime(date('Y/m/d H:i:s')); $datetime->modify('+1 day'); $enddate = $datetime->format('Y-m-d H:i:s'); $sq = "INSERT INTO products(ProductID,Pname,StartingPrice,SellerID,CategoryID,YearsofUsage,Details) values('" . $productCount . "','" . $title . "','" . $price . "','" . $user . "','" . $category . "','" . $years . "','" . $details . "')"; $sq2 = "INSERT INTO auction(ProductID,EndTime,CurrentPrice) values('" . $productCount . "','" . $enddate . "','" . $price . "')"; if ($conn->query($sq) === TRUE && $conn->query($sq2) === TRUE) { echo "New record created successfully"; header("location: index.php"); } else { echo "Error: " . $sq . "<br>" . $conn->error; } $conn->close();
preg_match("/993399">(((?!<).)+)/", $event->parent->title, $matches); $e['title'] = trim(ucwords($matches[1])); $e['description'] = $matches[1]; scraperwiki::save_sqlite(array('title', 'link', 'description', 'pubDate'), $e); } } $d->modify("+1 month"); } require 'scraperwiki/simple_html_dom.php'; $prevMonths = 0; //Number of weeks in the past $numMonths = 1; //Number of weeks to scrape //$events = "http://lichfield-cathedral.org/month.calendar/2011/12/06/112.html"; $d = new datetime(); $d->modify("-{$prevMonths} months"); for ($i = 0; $i < $numMonths; $i++) { $value = "http://lichfield-cathedral.org/month.calendar/" . $d->format("Y/m/d") . "/112.html"; $html = scraperwiki::scrape($value); $dom = new simple_html_dom(); $dom->load($html); foreach ($dom->find('td[@class=cal_td_dayshasevents]') as $data) { $aDay = $data->find("a[@class=cal_daylink]"); $date = $d->format("Y/m/") . $aDay[0]->innertext; foreach ($data->find("a[@class=cal_titlelink]") as $event) { $e = array(); $e['link'] = "http://lichfield-cathedral.org" . $event->href; $dt['date'] = $date; $t = $event->innertext; if (preg_match("/^\\d{1,2}:\\d{1,2}/", $t, $matches) != 0) { $dt['time'] = $matches[0];