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)); }
/** * Get all scores generated or changed at given date, limited by limit param * * @param datetime $_date * @param int $_limit * @return \Doctrine\Common\Collections\ArrayCollection|null */ public function getScoresByDate(datetime $_date, $_limit = 100) { $dql = 'SELECT s FROM Custom_Entity_Score s WHERE ( ( year(s.created_at) = ?1 AND month(s.created_at) = ?2 AND day(s.created_at) = ?3 ) OR ( year(s.changed_at) = ?1 AND month(s.changed_at) = ?2 AND day(s.changed_at) = ?3 ) )'; $em = $this->getEntityManager(); /** @var $query \Doctrine\ORM\Query */ $query = $em->createQuery($dql); $query->setParameters( array( 1 => $_date->format('Y'), //year 2 => $_date->format('m'), //month 3 => $_date->format('d') //day )); $query->setMaxResults((int) $_limit); /** @var $result Custom_Entity_Score */ $results = $query->getResult(); return $results; }
public function __construct($object = '', $description = '', $location = '') { $this->setId(-1); $this->setObject($object); $this->setDescription($description); $this->setLocation($location); $this->dateStart = new \DateTime(); $this->dateStart->add(new \DateInterval('P1D')); $this->dateStart->setTime($this->dateStart->format('H'), $this->dateStart->format('i') - $this->dateStart->format('i') % 15, $this->dateStart->format('s')); $this->dateEnd = new \DateTime(); $this->dateEnd->add(new \DateInterval('P1DT2H')); $this->dateEnd->setTime($this->dateEnd->format('H'), $this->dateEnd->format('i') - $this->dateEnd->format('i') % 15, $this->dateEnd->format('s')); $this->participants = new ArrayCollection(); $this->childs = new ArrayCollection(); }
/** * Returns the current timestamp in dd.mm.YYYY - HH:MM:SS format * @return string with the current date */ private function getTime() { //$date = new datetime("now", new DateTimeZone('Europe/Paris')); $date = new datetime("now"); return $date->format("d.m.Y | H:i:s"); //return date("d.m.Y | H:i:s"); }
public function getDueDate() { if (!$this->dueDate) { return null; } return $this->dueDate->format('Y-m-d H:i:s'); }
/** * Get pvp_range * * @return string */ public function getPvpRange() { if (!$this->pvp_von || !$this->pvp_bis) { return false; } $datum = $this->pvp_von->format('d.m.Y') . " - " . $this->pvp_bis->format('d.m.Y'); return $datum; }
private function getMessageList(Request $request) { // Build filters $filters = array(); $status = (int) $request->query->get('status'); if ($status) { $filters['status'] = $status; } if ($request->query->get('date') != '') { $filterDate = new \datetime($request->query->get('date')); $filters['sentAt'] = (string) $filterDate->format('Y-m-d'); } // Get message list $messages = $this->get('doctrine_mongodb')->getRepository('FortyTwoGroupMessengeBundle:Message')->findBy($filters, array('sentAt' => 'DESC')); return $messages; }
// 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();
/** * Ajax exec cron. * * @access public * @return void */ public function ajaxExec() { ignore_user_abort(true); set_time_limit(0); session_write_close(); /* Check cron turnon. */ if (empty($this->config->global->cron)) { die; } /* make cron status to running. */ $configID = $this->cron->getConfigID(); $configID = $this->cron->markCronStatus('running', $configID); /* Get and parse crons. */ $crons = $this->cron->getCrons('nostop'); $parsedCrons = $this->cron->parseCron($crons); /* Update last time. */ $this->cron->changeStatus(key($parsedCrons), 'normal', true); $this->loadModel('common'); $startedTime = time(); while (true) { /* When cron is null then die. */ if (empty($crons)) { break; } if (empty($parsedCrons)) { break; } if (!$this->cron->getTurnon()) { break; } /* Run crons. */ $now = new datetime('now'); $this->common->loadConfigFromDB(); foreach ($parsedCrons as $id => $cron) { $cronInfo = $this->cron->getById($id); /* Skip empty and stop cron.*/ if (empty($cronInfo) or $cronInfo->status == 'stop') { continue; } /* Skip cron that status is running and run time is less than max. */ if ($cronInfo->status == 'running' and time() - strtotime($cronInfo->lastTime) < $this->config->cron->maxRunTime) { continue; } /* Skip cron that last time is more than this cron time. */ if ($cronInfo->lastTime > $cron['time']->format(DT_DATETIME1)) { die; } if ($now > $cron['time']) { $this->cron->changeStatus($id, 'running'); $parsedCrons[$id]['time'] = $cron['cron']->getNextRunDate(); /* Execution command. */ $output = ''; $return = ''; if ($cron['command']) { if (isset($crons[$id]) and $crons[$id]->type == 'zentao') { parse_str($cron['command'], $params); if (isset($params['moduleName']) and isset($params['methodName'])) { $this->app->loadConfig($params['moduleName']); $output = $this->fetch($params['moduleName'], $params['methodName']); } } elseif (isset($crons[$id]) and $crons[$id]->type == 'system') { exec($cron['command'], $output, $return); if ($output) { $output = join("\n", $output); } } /* Save log. */ $log = ''; $time = $now->format('G:i:s'); $log = "{$time} task " . $id . " executed,\ncommand: {$cron['command']}.\nreturn : {$return}.\noutput : {$output}\n"; $this->cron->logCron($log); unset($log); } /* Revert cron status. */ $this->cron->changeStatus($id, 'normal'); } } /* Check whether the task change. */ $newCrons = $this->cron->getCrons('nostop'); $changed = $this->cron->checkChange(); if (count($newCrons) != count($crons) or $changed) { $crons = $newCrons; $parsedCrons = $this->cron->parseCron($newCrons); } /* Sleep some seconds. */ $sleepTime = 60 - (time() - $now->getTimestamp()) % 60; sleep($sleepTime); /* Break while. */ if (connection_status() != CONNECTION_NORMAL) { break; } if ((time() - $startedTime) / 3600 / 24 >= $this->config->cron->maxRunDays) { break; } } /* Revert cron status to stop. */ $this->cron->markCronStatus('stop', $configID); }
public function getCreated() { return $this->created->format('Y-m-d H:i:s'); }
public function findNextEventsByCategory($category) { $today = new \datetime(); $query = $this->createQueryBuilder('e')->where('e.category = :category')->andWhere('e.startDate > :today')->setParameter('category', $category)->setParameter('today', $today->format('Y-m-d'))->orderBy('e.startDate', 'ASC'); return $query->getQuery()->getResult(); }
</ul> <?php } ?> </li> </ul> <div class="navbar-form navbar-right"> <?php if ($page == 'index.php') { //$date = new datetime("now", new DateTimeZone('Europe/Paris')); $date = new datetime("now"); echo '<button type="button" id="date_avant" class="btn btn-primary"><strong><<</strong></button>'; echo ' <input type="text" id="date_encours" class="form-control" style="width:100px"; value="' . $date->format("d/m/Y") . '">'; //echo ' <input type="text" id="date_encours" class="form-control" style="width:100px"; value="'.date("d/m/Y").'">'; echo '<button type="button" id="date_apres" class="btn btn-primary"><strong>>></strong></button>'; } ?> </div> </div><!--/.nav-collapse --> </div> </div> <div class="modal fade" id="login-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" > <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h2>Espace membre</h2>
/** * Get datCadastro * * @return datetime */ public function getDatCadastro() { return $this->datCadastro->format('d/m/Y H:i:s'); }
/** * @return null */ public function getDateCreated() { return $this->dateCreated ? $this->dateCreated->format('Y-m-d H:i:s') : null; }
function ShowPendingClaims() { ?> <h2>Pending claims</h2> <p>List of all outstanding claims on journo profile pages:</p> <?php $sql = <<<EOT SELECT p.id as person_id,p.name,p.email,perm.created,perm.permission,j.id as journo_id,j.ref,j.prettyname,j.oneliner FROM ( person p INNER JOIN person_permission perm ON perm.person_id=p.id) INNER JOIN journo j ON perm.journo_id=j.id WHERE perm.permission='claimed' ORDER BY perm.created ASC; EOT; $pending = db_getAll($sql); if ($pending) { foreach ($pending as &$p) { $d = new datetime($p['created']); $p['pretty_created'] = $d->format('Y-m-d'); } unset($p); ?> <p><?php echo sizeof($pending); ?> claims pending: </p> <ul> <?php foreach ($pending as $p) { ?> <li> <?php echo $p['pretty_created']; ?> : <a href="mailto:<?php echo $p['email']; ?> "><?php echo $p['email']; ?> </a> <?php if ($p['name']) { ?> ( <?php echo $p['name']; ?> ) <?php } ?> claims to be <?php echo journo_link($p); ?> [<a href="/adm/claims?person_id=<?php echo $p['person_id']; ?> &journo_id=<?php echo $p['journo_id']; ?> &action=approve">approve</a>] [<a href="/adm/claims?person_id=<?php echo $p['person_id']; ?> &journo_id=<?php echo $p['journo_id']; ?> &action=deny">deny</a>] </li> <?php } ?> </ul> <?php } else { ?> <p>No claims pending</p> <?php } }
while (true) { /* If need parse again, re parse the cron files. */ if (needParseAgain($cronPath, $lastParsed)) { echo "\ncron files changed, re parse them..."; $crons = parseCron($cronPath); $lastParsed = time(); printCrons($crons); } $now = new datetime('now'); foreach ($crons as $key => $cron) { if ($now > $cron['time']) { $crons[$key]['time'] = $cron['cron']->getNextRunDate(); $output = array(); $log = ''; exec($cron['command'], $output, $return); $time = $now->format('G:i:s'); foreach ($output as $out) { $log .= $out . "\n"; } $log = "{$time} task " . ($key + 1) . " executed,\ncommand: {$cron['command']}.\nreturn : {$return}.\noutput : {$log}\n"; echo $log; logCron($log); } } sleep(40); } /* Parse cron file. */ function parseCron($path) { chdir($path); $crons = array();
ce code un peu plus tard ! */ $d = new datetime($Post_Time); if (user_data('Account_ID') == $Post_Createur) { echo '<td id=p_' . $Post_ID . '>Posté à ' . $d->format('H\\hi \\l\\e d M y') . ' <a href="' . get_link('Poster', 'Guild', array('action' => 'delete', 'p' => $Post_ID)) . '"><span alt="Supprimer" title="Supprimer ce message" >✗</span></a> <a href="' . get_link('Poster', 'Guild', array('action' => 'edit', 'p' => $Post_ID)) . '"><span alt="Editer" title="Editer ce message" >✓</span></a></td></tr>'; } else { echo '<td> Posté à ' . $d->format('H\\hi \\l\\e d M y') . ' </td></tr>'; } $d = new datetime($Account_Inscription); //Détails sur le Account qui a posté echo '<tr><td> <img src="./images/avatars/' . $Account_Avatar . '" alt="" /> <br />Membre inscrit le ' . $d->format('d/m/Y') . ' <br />Messages : ' . $Account_Post . '<br /> Localisation : ' . $Account_localisation . '</td>'; //Message echo '<td>' . bb_code($Post_texte) . ' <br /><hr />' . bb_code($Account_Signature) . '</td></tr>'; } //Fin de la boucle ! \o/ ?> </table> <?php echo '<p>Page : '; for ($i = 1; $i <= $nombreDePages; $i++) { //On affiche pas la page actuelle en lien echo $i == $numpage ? $i : '<a href="' . get_link('Topic', 'Guild', array('t' => $Topic_ID, 'page' => $i)) . '">' . $i . '</a> ';
/** * Retrieve Google events on a date range * * @param string $calendarId * @param datetime $start Range start * @param datetime $end Range end * * @return object */ public function getEventsOnRange($calendarId, $start, $end) { $service = $this->getCalendarService(); $timeMin = $start->format(\DateTime::RFC3339); $timeMax = $end->add(new \DateInterval('P90D'))->format(\DateTime::RFC3339); // Params to send to Google $eventOptions = array('timeMin' => $timeMin, 'timeMax' => $timeMax); $eventList = $service->events->listEvents($calendarId, $eventOptions); return $eventList; }
$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]; } else { $dt['time'] = '0:00';
/** * Update existing event * if eventTemplate is given in $params get data from there, else use services * * @param array $params * @throws CTException */ function churchservice_updateEvent($params, $csevent) { global $user; include_once CHURCHCAL . '/churchcal_db.php'; // Delete action, e.g. when adding Exceptions to CalEvent if (isset($csevent["action"]) && $csevent["action"] == "delete") { churchservice_deleteEvent($csevent); return; } // update/insert cs_event $fields = array(); if (isset($csevent["startdate"])) { $fields["startdate"] = $csevent["startdate"]; } if (isset($csevent["valid_yn"])) { $fields["valid_yn"] = $csevent["valid_yn"]; } if (isset($csevent["special"])) { $fields["special"] = $csevent["special"]; } if (isset($csevent["admin"])) { $fields["admin"] = $csevent["admin"]; } $event_id = $csevent["id"]; db_update("cs_event")->fields($fields)->condition('id', $event_id, "=")->execute(); if (!empty($params["services"])) { // update/insert eventservices $rm_services = array(); $new_services = array(); $dt = new datetime(); $fields = array("event_id" => $event_id, "valid_yn" => 1, "modified_date" => $dt->format('Y-m-d H:i:s'), "modified_pid" => $user->id); foreach ($params["services"] as $key => $val) { $fields["service_id"] = $key; $fields["counter"] = null; $i = $val; while ($i > 0) { $fields["counter"] = $i--; db_insert("cs_eventservice")->fields($fields)->execute(); } } } }
/** * save fact * @param unknown $params */ function churchservice_saveFact($params) { global $user; $event_id = $params["event_id"]; $fact_id = $params["fact_id"]; $value = $params["value"]; $dt = new datetime(); if ($value == "") { db_query("DELETE FROM {cs_event_fact} WHERE event_id={$event_id} and fact_id={$fact_id}"); } else { db_query("INSERT INTO {cs_event_fact} (event_id, fact_id, value, modified_date, modified_pid)\n VALUES ({$event_id}, {$fact_id}, {$value}, '" . $dt->format('Y-m-d H:i:s') . "', {$user->id})\n ON DUPLICATE KEY UPDATE value={$value}, modified_pid={$user->id}, modified_date='" . $dt->format('Y-m-d H:i:s') . "'"); } cdb_log("[ChurchService] Speichere Fakt {$value} bei Fakt {$fact_id}, Event {$event_id}", 2, $fact_id, "fact"); }
/** * Infos f�r noch zu best�tigende Dienste */ function churchservice_openservice_rememberdays() { global $base_url; include_once "churchservice_db.php"; $delay = readConf('churchservice_openservice_rememberdays'); $dt = new datetime(); // Checken, ob EIN EventService noch nicht gesendet wurde, bzw. schon so alt ist. // Pr�fe dabei, ob die Person eine EMail-Adresse hat und auch gemappt wurde. $sql = "SELECT es.id, p.id p_id, p.vorname, p.email, es.modified_pid, if (password is null and loginstr is null and lastlogin is null,1,0) as invite \n FROM {cs_eventservice} es, {cs_event} e, {cc_cal} cal, {cs_service} s, {cdb_person} p \n where e.valid_yn=1 and e.cc_cal_id=cal.id and es.valid_yn=1 and es.zugesagt_yn=0 and es.cdb_person_id is not null\n and es.service_id=s.id and s.sendremindermails_yn=1 \n and es.event_id=e.id and e.Startdate>=current_date\n and ((es.mailsenddate is null) or (datediff(current_date,es.mailsenddate)>={$delay}))\n and p.email!='' and p.id=es.cdb_person_id limit 1"; $res = db_query($sql)->fetch(); $sql2 = "SELECT es.id id, cal.bezeichnung event, DATE_FORMAT(e.startdate, '%d.%m.%Y %H:%i') datum, e.id event_id,\n s.bezeichnung service, sg.bezeichnung servicegroup, es.mailsenddate\n FROM {cs_eventservice} es, {cs_event} e, {cc_cal} cal, {cs_service} s, {cs_servicegroup} sg \n where e.valid_yn=1 and cal.id=e.cc_cal_id and es.valid_yn=1 and es.zugesagt_yn=:zugesagt and es.cdb_person_id=:p_id\n and s.sendremindermails_yn=1 \n and es.event_id=e.id and es.service_id=s.id and sg.id=s.servicegroup_id\n and e.startdate>=current_date\n order by e.startdate"; $i = 0; // Lasse 15 EventServices durch, dann warten bis n�chste Cron, sonst werden es zu viele Mails while ($res && $i < 15) { // Wenn einer vorhanden ist, dann suche nach weiteren offenen Diensten f�r die Person $txt = "<h3>Hallo " . $res->vorname . ",</h3><p>"; $inviter = churchcore_getPersonById($res->modified_pid); $txt .= "Du wurdest in dem Dienstplan auf " . readConf('site_name', 'ChurchTools'); if ($inviter != null) { $txt .= ' von <i>' . $inviter->vorname . " " . $inviter->name . "</i>"; } $txt .= " zu Diensten vorgeschlagen. <br/>Zum Zu- oder Absagen bitte hier klicken:"; $loginstr = churchcore_createOnTimeLoginKey($res->p_id); $txt .= '<p><a href="' . $base_url . '?q=home&id=' . $res->p_id . '&loginstr=' . $loginstr . '" class="btn btn-primary">%sitename</a>'; $txt .= "<p><p><b>Folgende Dienst-Termine sind von Dir noch nicht bearbeitet:</b><ul>"; $arr = db_query($sql2, array(":p_id" => $res->p_id, ":zugesagt" => 0)); foreach ($arr as $res2) { $txt .= "<li> " . $res2->datum . " " . $res2->event . ": " . $res2->service . " (" . $res2->servicegroup . ")"; db_update("cs_eventservice")->fields(array("mailsenddate" => $dt->format('Y-m-d H:i:s')))->condition('id', $res2->id, "=")->execute(); } $txt .= '</ul>'; $arr = db_query($sql2, array(":p_id" => $res->p_id, ":zugesagt" => 1)); $txt2 = ""; foreach ($arr as $res2) { $txt2 .= "<li> " . $res2->datum . " - " . $res2->event . ": " . $res2->service . " (" . $res2->servicegroup . ")"; if ($res2->mailsenddate == null) { $txt2 .= " NEU!"; } db_update("cs_eventservice")->fields(array("mailsenddate" => $dt->format('Y-m-d H:i:s')))->condition('id', $res2->id, "=")->execute(); } if ($txt2 != "") { $txt .= "<p><p><b>Bei folgenden Diensten hast Du schon zugesagt:</b><ul>" . $txt2; $txt .= "</ul>"; } // Person wurde noch nicht eingeladen, also schicke gleich eine Einladung mit! if ($res->invite == 1) { include_once CHURCHDB . '/churchdb_ajax.php'; churchdb_invitePersonToSystem($res->p_id); $txt .= "<p><b>Da Du noch nicht kein Zugriff auf das System hast, bekommst Du noch eine separate E-Mail, mit der Du Dich dann anmelden kannst!.</b>"; } churchservice_send_mail("[" . readConf('site_name', 'ChurchTools') . "] Es sind noch Dienste offen", $txt, $res->email); $i = $i + 1; $res = db_query($sql)->fetch(); } }
/** * Get pvr_gueltig_bis * * @return \DateTime */ public function getPvrGueltigBis() { return $this->pvr_gueltig_bis->format('d.m.Y'); }
function article_collect($article_id, $sim_orderby = 'score', $sim_showall = 'no') { $art = db_getRow('SELECT * FROM article WHERE id=?', $article_id); if (is_null($art)) { return null; } $art['article_id'] = $art['id']; $art['id36'] = article_id_to_id36($art['id']); $art['blog_links'] = db_getAll("SELECT * FROM article_bloglink WHERE article_id=? ORDER BY linkcreated DESC", $article_id); // journos $sql = <<<EOT SELECT j.prettyname, j.ref FROM ( journo j INNER JOIN journo_attr attr ON j.id=attr.journo_id ) WHERE attr.article_id=? AND j.status='a'; EOT; $art['journos'] = db_getAll($sql, $article_id); $art['byline'] = article_markup_byline($art['byline'], $art['journos']); $orginfo = db_getRow("SELECT * FROM organisation WHERE id=?", $art['srcorg']); $art['srcorgname'] = $orginfo['prettyname']; $art['sop_name'] = $orginfo['sop_name']; $art['sop_url'] = $orginfo['sop_url']; $art['srcorg_url'] = $orginfo['home_url']; $permalink = $art['permalink']; $d = new datetime($art['pubdate']); $art['pretty_pubdate'] = pretty_date(strtotime($art['pubdate'])); $art['iso_pubdate'] = $d->format('c'); $art['buzz'] = BuzzFragment($art); /* similar articles */ if ($sim_orderby == 'date') { $ord = 'a.pubdate DESC, s.score DESC'; } else { // 'score' $ord = 's.score DESC, a.pubdate DESC'; } $sql = <<<EOT SELECT a.id,a.title, a.srcorg,a.byline,a.permalink,a.pubdate FROM article a INNER JOIN article_similar s ON s.other_id=a.id WHERE s.article_id=? and a.status='a' ORDER BY {$ord} EOT; /* only the first 10 by default */ if ($sim_showall != 'yes') { $sql .= " LIMIT 10"; } $sim_arts = db_getAll($sql, $article_id); foreach ($sim_arts as &$s) { article_augment($s); } unset($s); $art['sim_orderby'] = $sim_orderby; $art['sim_showall'] = $sim_showall; $art['sim_arts'] = $sim_arts; $tags = db_getAll('SELECT tag, freq FROM article_tag WHERE article_id=? ORDER BY freq DESC', $article_id); $sorted_tags = array(); foreach ($tags as $t) { $sorted_tags[$t['tag']] = intval($t['freq']); } ksort($sorted_tags); $art['tags'] = $sorted_tags; $art['comment_links'] = article_collect_commentlinks($article_id); return $art; }
/** * Return the correct date and time format * * @global array $_ARRAYLANG * * @param datetime $time * * @return string */ public static function formattedDateAndTime($time) { global $_ARRAYLANG; return $time->format('d.m.Y - H.i') . ' ' . $_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_LABEL_CLOCK']; }
function churchservice_saveEvent($params, $source = null) { global $user; include_once CHURCHCAL . '/churchcal_db.php'; $cal_id = null; if ($source == "churchcal" && $params["id"] == null && isset($params["cal_id"])) { $cal_id = $params["cal_id"]; } else { // Hole mir erst mal die zugeh�rige cc_cal_id, falls es das Event schon gibt. if (isset($_GET["id"])) { $cal_id = db_query("select cc_cal_id from {cs_event} where id=:id", array(":id" => $_GET["id"]))->fetch()->cc_cal_id; } } // Erst mal das cs_event updated/inserten $fields = array(); if (isset($params["startdate"])) { $fields["startdate"] = $params["startdate"]; } if (isset($params["valid_yn"])) { $fields["valid_yn"] = $params["valid_yn"]; } if ($source == null) { $fields["special"] = isset($params["special"]) ? $params["special"] : ""; $fields["admin"] = isset($params["admin"]) ? $params["admin"] : ""; } if (isset($params["eventTemplate"])) { $db = db_query('select special, admin from {cs_eventtemplate} where id=:id', array(":id" => $params["eventTemplate"]))->fetch(); if ($db != false) { if (!isset($fields["special"]) || �($fields["special"] == "")) { $fields["special"] = $db->special; } if (!isset($fields["admin"]) || �($fields["admin"] == "")) { $fields["admin"] = $db->admin; } } } if (isset($params["id"])) { $event_id = $params["id"]; db_update("cs_event")->fields($fields)->condition('id', $params["id"], "=")->execute(); // BENACHRICHTIGE ANDERE MODULE if ($source == null && $cal_id != null) { $cal_params = array_merge(array(), $params); $cal_params["event_id"] = $event_id; $cal_params["id"] = $cal_id; churchcal_updateEvent($cal_params, "churchservice"); } } else { if ($source == null) { $params["repeat_id"] = 0; $params["intern_yn"] = 0; $params["notizen"] = ""; $params["link"] = ""; $params["ort"] = ""; $cal_id = churchcal_createEvent($params, "churchservice"); } $fields["cc_cal_id"] = $cal_id; if (isset($params["eventTemplate"])) { $fields["created_by_template_id"] = $params["eventTemplate"]; } $event_id = db_insert("cs_event")->fields($fields)->execute(); } if (!isset($params["eventTemplate"]) && isset($params["services"])) { // Nun die Eintr�ge updaten/inserten $rm_services = array(); $new_services = array(); $fields = array(); $fields["event_id"] = $event_id; $dt = new datetime(); $fields["valid_yn"] = 1; $fields["modified_date"] = $dt->format('Y-m-d H:i:s'); $fields["modified_pid"] = $user->id; foreach ($params["services"] as $key => $arr) { $fields["service_id"] = $key; $fields["counter"] = null; if ($arr == 1) { db_insert("cs_eventservice")->fields($fields)->execute(); } else { $i = $arr; while ($i > 0) { $fields["counter"] = $i; $i--; db_insert("cs_eventservice")->fields($fields)->execute(); } } } } else { if (isset($params["eventTemplate"])) { if (isset($params["id"])) { print_r($params); throw new CTException("Es kann kein Template uebergeben werden, wenn der Service schon existiert!"); } $fields = array(); $fields["event_id"] = $event_id; $fields["valid_yn"] = 1; $dt = new datetime(); $fields["modified_date"] = $dt->format('Y-m-d H:i:s'); $fields["modified_pid"] = $user->id; $db = db_query("select * from {cs_eventtemplate_service} where eventtemplate_id=:eventtemplate_id", array(':eventtemplate_id' => $params["eventTemplate"])); foreach ($db as $d) { $fields["service_id"] = $d->service_id; if ($d->count == 1) { $fields["counter"] = null; db_insert("cs_eventservice")->fields($fields)->execute(); } else { $i = $d->count; while ($i > 0) { $fields["counter"] = $i; $i--; db_insert("cs_eventservice")->fields($fields)->execute(); } } } ct_log("[ChurchService] Lege Template an " . $params["eventTemplate"] . " fuer Event", 2, $event_id, "service"); } } }
/** * Get last update time * * @return string formatted date */ public function getUpdatedAt() { return $this->updated_at->format('d M. Y'); }
function churchcal_getAllowedCategories($withPrivat = true, $onlyIds = false) { global $user; $withPrivat = false; include_once CHURCHDB . "/churchdb_db.php"; $db = db_query("select * from {cc_calcategory}"); $res = array(); $auth = churchcal_getAuthForAjax(); $privat_vorhanden = false; foreach ($db as $category) { if ($category->privat_yn == 1 && $category->modified_pid == $user->id) { $privat_vorhanden = true; } if ($category->privat_yn == 0 || $withPrivat) { // Zugriff, weil ich View-Rechte auf die Kategorie habe if (isset($auth["view category"]) && isset($auth["view category"][$category->id]) || isset($auth["edit category"]) && isset($auth["edit category"][$category->id])) { if ($onlyIds) { $res[$category->id] = $category->id; } else { $res[$category->id] = $category; } } } } if (!$privat_vorhanden && $user->id > 0 && user_access("personal category", "churchcal")) { $dt = new datetime(); $id = db_insert("cc_calcategory")->fields(array("bezeichnung" => $user->vorname . "s Kalender", "sortkey" => 0, "oeffentlich_yn" => 0, "privat_yn" => 1, "color" => "black", "modified_date" => $dt->format('Y-m-d H:i:s'), "modified_pid" => $user->id))->execute(); // Add permission for person who created the event db_query("insert into {cc_domain_auth} (domain_type, domain_id, auth_id, daten_id)\n values ('person', {$user->id}, 404, {$id})"); $_SESSION["user"]->auth = getUserAuthorization($_SESSION["user"]->id); churchcore_saveUserSetting("churchcal", $user->id, "filterMeineKalender", "[" . ($id + 100) . "]"); return churchcal_getAllowedCategories($withPrivat, $onlyIds); } else { return $res; } }
function cache_status() { /* show the cache status and offer to rebuild */ global $wpdb; global $amain; $problem = false; $now = time(); $dt = new DateTime('now', $this->tz); $nowtxt = date_format($dt, 'D, j M Y G:i e'); if (is_admin()) { if (!($amain = ausers_get_option('amr-users-main'))) { $amain = ameta_default_main(); } $wpdb->show_errors(); $sql = 'SELECT DISTINCT reportid AS "rid", COUNT(reportid) AS "lines" FROM ' . $this->table_name . ' GROUP BY reportid'; $results = $wpdb->get_results($sql, ARRAY_A); /* Now e have a summary of what isin the cache table - rid, lines */ if (is_wp_error($results)) { echo '<h2>' . $results->get_error_message() . '</h2>'; return false; } else { if (!empty($results)) { //var_dump($results); var_dump($amain); foreach ($results as $i => $rpt) { $r = intval(substr($rpt['rid'], 5)); /* *** skip the 'users' and take the rest */ $summary[$r]['rid'] = $rpt['rid']; $summary[$r]['lines'] = $rpt['lines'] - 2; /* as first two liens are headers anyway*/ $summary[$r]['name'] = $amain['names'][intval($r)]; } } else { echo adb_cache::get_error('nocacheany'); // attempt a realtime run NO!!! Don't do this - for large databases that are failing anyway will be no good. //foreach ($amain['names'] as $i => $name) { // amr_build_user_data_maybe_cache($i); //} } $status = ausers_get_option('amr-users-cache-status'); /* Now pickup the record of starts etc reportid, start and reportid end*/ if (!empty($status)) { foreach ($status as $rd => $se) { $r = intval(substr($rd, 5)); /* *** skip the 'users' and take the rest */ if (empty($se['end'])) { $now = time(); $diff = $now - $se['start']; if ($diff > 60 * 5) { $problem = true; $summary[$r]['end'] = __('Taking too long, may have been aborted... delete cache status, try again, check server logs and/or memory limit', 'amr-users'); delete_transient('amr_users_cache_' . $r); // so another can run } else { $summary[$r]['end'] = sprintf(__('Started %s', 'amr-users'), human_time_diff($now, $se['start'])); } $summary[$r]['time_since'] = __('?', 'amr-users'); $summary[$r]['time_taken'] = __('?', 'amr-users'); $summary[$r]['peakmem'] = __('?', 'amr-users'); $summary[$r]['rid'] = $rd; $r = intval(substr($rd, 5)); /* *** skip the 'users' and take the rest */ $summary[$r]['name'] = $amain['names'][intval($r)]; } else { if (empty($se['end'])) { $summary[$r]['end'] = 'In progress'; } else { $datetime = new datetime(date('Y-m-d H:i:s', $se['end'])); if (empty($tzobj)) { $tzobj = amr_getset_timezone(); } $datetime->setTimezone($tzobj); $summary[$r]['end'] = $datetime->format('D, j M G:i'); } //$summary[$r]['end'] = empty($se['end']) ? 'In progress' : date_i18n('D, j M H:i:s',$se['end']); /* this is in unix timestamp not "our time" , so just say how long ago */ $summary[$r]['start'] = date_i18n('D, j M Y H:i:s', $se['start']); /* this is in unix timestamp not "our time" , so just say how long ago */ $dt = new DateTime('now', $this->tz); $nowtxt = date_format($dt, 'D, j M Y G:i e'); $summary[$r]['time_since'] = human_time_diff($se['end'], time()); /* the time that the last cache ended */ $summary[$r]['time_taken'] = $se['end'] - $se['start']; /* the time that the last cache ended */ $summary[$r]['peakmem'] = $se['peakmem']; $summary[$r]['headings'] = $se['headings']; } } } else { if (!empty($summary)) { foreach ($summary as $rd => $rpt) { $summary[$rd]['time_since'] = $summary[$rd]['time_taken'] = $summary[$rd]['end'] = $summary[$rd]['peakmem'] = ''; } } } if (!empty($summary)) { echo PHP_EOL . '<div class="wrap" style="padding-top: 20px;">' . '<h3>' . $nowtxt . '</h3>' . PHP_EOL . '<table class="widefat" style="width:auto; ">' . '<thead><tr><th>' . __('Report Id', 'amr-users') . '</th><th>' . __('Name', 'amr-users') . '</th><th>' . __('Lines', 'amr-users') . '</th><th style="text-align: right;">' . __('Ended?', 'amr-users') . '</th><th style="text-align: right;">' . __('How long ago?', 'amr-users') . '</th><th style="text-align: right;">' . __('Seconds taken', 'amr-users') . '</th><th style="text-align: right;">' . __('Peak Memory', 'amr-users') . '</th><th style="text-align: right;">' . __('Details', 'amr-users') . '</th></tr></thead>'; foreach ($summary as $rd => $rpt) { if (!isset($rpt['headings'])) { $rpt['headings'] = ' '; } if (!isset($rpt['lines'])) { $rpt['lines'] = ' '; } if (isset($rpt['rid'])) { echo '<tr>' . '<td>' . $rpt['rid'] . '</td>' . '<td>' . au_view_link($rpt['name'], $rd, '') . '</td>' . '<td align="right">' . $rpt['lines'] . '</td>' . '<td align="right">' . $rpt['end'] . '</td>' . '<td align="right">' . $rpt['time_since'] . '</td>' . '<td align="right">' . $rpt['time_taken'] . '</td>' . '<td align="right">' . $rpt['peakmem'] . '</td>' . '<td align="right">' . $rpt['headings'] . '</td>' . '</tr>'; } } echo PHP_EOL . '</table>' . PHP_EOL . '</div><!-- end wrap -->' . PHP_EOL; } } } else { echo '<h3>not admin?</h3>'; } if ($problem) { $fun = '<a target="_blank" title="' . __('Link to audio file of the astronauts of Apollo 13 reporting a problem.', 'amr-users') . '" href="http://upload.wikimedia.org/wikipedia/commons/1/12/Apollo13-wehaveaproblem_edit_1.ogg" >' . __('Houston, we have a problem', 'amr-users') . '</a>'; $text = __('The background job\'s may be having problems.', 'amr-users'); $text .= '<br />' . __('Delete all the cache records and try again', 'amr-users'); $text .= '<br />' . __('Check the server logs and your php wordpress memory limit.', 'amr-users'); $text .= '<br />' . __('The TPC memory usage plugin may be useful to assess whether the problem is memory.', 'amr-users'); $text = $fun . '<br/>' . $text; amr_users_message($text); } }
/** * info for pending requests * TODO: rename churchservice_openservice_rememberdays, f.e. to sendOpenServiceRememberMail * TODO: could sql queries be reduced? */ function churchservice_openservice_rememberdays() { global $base_url; include_once "churchservice_db.php"; $delay = (int) getConf('churchservice_openservice_rememberdays'); $dt = new datetime(); // get ONE eventService needed to send (not yet send or still pending). // from persons having an email ??und auch gemappt wurde??. // $sql = "SELECT es.id, p.id p_id, p.vorname, p.email, es.modified_pid, // IF (password IS NULL AND loginstr IS NULL AND lastlogin IS NULL,1,0) AS invite // FROM {cs_eventservice} es, {cs_event} e, {cc_cal} cal, {cs_service} s, {cdb_person} p // WHERE e.valid_yn=1 AND e.cc_cal_id=cal.id AND es.valid_yn=1 AND es.zugesagt_yn=0 // AND es.cdb_person_id IS NOT NULL AND es.service_id=s.id AND s.sendremindermails_yn=1 // AND es.event_id=e.id AND e.Startdate>=current_date // AND ((es.mailsenddate IS NULL) OR (DATEDIFF(current_date,es.mailsenddate)>=$delay)) // AND p.email!='' AND p.id=es.cdb_person_id LIMIT 1"; $sql = "SELECT es.id, p.id p_id, p.vorname, p.spitzname, p.name, p.email, es.modified_pid,\n IF (password IS NULL AND loginstr IS NULL AND lastlogin IS NULL,1,0) AS invite\n FROM {cs_eventservice} es, {cs_event} e, {cc_cal} cal, {cs_service} s, {cdb_person} p\n WHERE e.valid_yn=1 AND e.cc_cal_id=cal.id AND es.valid_yn=1 AND es.zugesagt_yn=0\n AND es.cdb_person_id IS NOT NULL AND es.service_id=s.id AND s.sendremindermails_yn=1\n AND es.event_id=e.id AND e.Startdate>=current_date\n AND ((es.mailsenddate IS NULL) OR (DATEDIFF(current_date,es.mailsenddate)>={$delay}))\n AND p.email!='' AND p.id=es.cdb_person_id\n GROUP BY p_id"; //group to get each person only once, so querying all together dont interfere with the other services of the same person $usersToMail = db_query($sql); $i = 0; // process only 15 services to prevent too many mails at once while ($i++ < 15 && ($u = $usersToMail->fetch())) { $data = array('inviter' => churchcore_getPersonById($u->modified_pid), 'url' => "{$base_url}?q=home&id={$u->p_id}&loginstr=" . churchcore_createOnTimeLoginKey($u->p_id), 'requestedServices' => array(), 'approvedServices' => array(), 'user' => $u, 'nickname' => $u->spitzname ? $u->spitzname : $u->vorname); // Person was not yet invited -> send invitation. if ($u->invite == 1) { include_once CHURCHDB . '/churchdb_ajax.php'; churchdb_invitePersonToSystem($u->p_id); } $servicesOfPerson = db_query("\n SELECT es.id AS id, es.zugesagt_yn AS approved, cal.bezeichnung AS event, DATE_FORMAT(e.startdate, '%d.%m.%Y %H:%i') AS datum,\n e.id AS event_id, s.bezeichnung AS service, sg.bezeichnung AS servicegroup, es.mailsenddate\n FROM {cs_eventservice} es, {cs_event} e, {cc_cal} cal, {cs_service} s, {cs_servicegroup} sg\n WHERE e.valid_yn=1 AND cal.id=e.cc_cal_id AND es.valid_yn=1 AND es.cdb_person_id=:p_id\n AND s.sendremindermails_yn=1 AND es.event_id=e.id AND es.service_id=s.id AND sg.id=s.servicegroup_id\n AND e.startdate>=current_date\n ORDER BY e.startdate", array(":p_id" => $u->p_id)); foreach ($servicesOfPerson as $s) { if ($s->approved == 1) { $data['approvedServices'][] = $s; } else { $data['requestedServices'][] = $s; } db_update("cs_eventservice")->fields(array("mailsenddate" => $dt->format('Y-m-d H:i:s')))->condition('id', $s->id, "=")->execute(); } $lang = getUserLanguage($u->p_id); $content = getTemplateContent('email/openServiceReminder', 'churchservice', $data, null, $lang); churchservice_send_mail("[" . getConf('site_name') . "] " . t2($lang, 'there.are.pending.services'), $content, $u->email); $usersToMail->next(); } }