/** * find the difference between two date * * @param datetime $start * @param datetime $end * * @return string */ public static function diffTime($start, $end) { if (empty($start) || empty($end)) { return; } $duration = $end->diff($start); return $duration->format('%H:%I:%S'); }
/** * @param string $format * @return null */ public function getExecutionTimeString($format = '%H hours, %I minutes, %S seconds') { $time = null; if ($this->getState() == self::STATE_FINISHED) { $time = $this->finishedAt->diff($this->startedAt)->format($format); } return $time; }
function showIdentityTab() { $this->getEnumMappings(); $this->getAliases(); $chapter=sprintf(_("SIP Account")); $this->showChapter($chapter); print " <div class='row-fluid'> <div class=span12> <table class='table table-condensed table-striped'> <tr> <td style=\"width: 20%\">"; print _("SIP Address"); print "</td> <td>sip:$this->account</td> </tr>"; /* print " <tr> <td>"; print _("Full Name"); print " </td> <td>$this->fullName </td> </tr> "; */ print " <tr> <td>"; print _("Username"); print "</td> <td>$this->username</td> </tr>"; print " <tr> <td>"; print _("Domain/Realm"); print "</td> <td>$this->domain</td> </tr>"; print " <tr> <td>"; print _("Outbound Proxy"); print "</td> <td>$this->sip_proxy</td> </tr> "; if ($this->xcap_root) { print " <tr> <td>"; print _("XCAP Root"); print " </td> <td>$this->xcap_root </td> </tr> "; } print "</table></div></div>"; if ($this->pstn_access && $this->rpid) { $chapter=sprintf(_("PSTN")); $this->showChapter($chapter); print " <div class=row-fluid> <div class=span12> <table class='table table-condensed table-striped'><tr><td style=\"width: 20%\">"; print _("Caller-ID"); print "</td> <td>$this->rpid</td> </tr> "; $t=0; foreach($this->enums as $e) { $t++; $rr=floor($t/2); $mod=$t-$rr*2; if ($mod ==0) { $_class='odd'; } else { $_class='even'; } print " <tr> <td>"; print _("Phone Number"); print "</td> <td>$e</td> </tr> "; } print "</table></div></div>"; } $chapter=sprintf(_("Aliases")); $this->showChapter($chapter); print " <div class=row-fluid> <div class=span12>"; printf (_("You may create new aliases for incoming calls")); printf (" </div> </div> "); $t=0; print " <form class=form-horizontal method=post name=sipsettings onSubmit=\"return checkForm(this)\"> "; foreach($this->aliases as $a) { $t++; $rr=floor($t/2); $mod=$t-$rr*2; if ($mod ==0) { $_class='even'; } else { $_class='odd'; } print " <div class='control-group $_class'> <label for=aliases[] class=control-label>"; print _("SIP Alias"); print " </label> <div class='controls'><input type=text size=35 name=aliases[] value=\"$a\"> </div> </div> "; } print " <div class='control-ground $_class'> <label for=aliases[] class=control-label>"; print _("New SIP Alias"); print " </label>"; print " <div class=controls> <input type=hidden name=action value=\"set aliases\"> "; print ' <input name=aliases[] size="35" type="text"> </div><div class=form-actions> <input class="btn" type="submit" value="'; print _("Save aliases"); print '" onClick=saveHandler(this)> </div> </div> '; print $this->hiddenElements; print " </form> "; if (!$this->isEmbedded() && $this->show_tls_section) { if ($this->enrollment_url) { include($this->enrollment_configuration); if (is_array($enrollment)) { $chapter=sprintf(_("TLS Certificate")); $this->showChapter($chapter); print " <tr> <td>"; print _("X.509 Format"); printf (" </td> <td><a href=%s&action=get_crt>Certificate</a> </td> </tr> ",$this->url); /* print " <tr> <td>"; print _("PKCS#12 store format"); printf (" </td> <td><a href=%s&action=get_p12>Certificate</a> </td> </tr> <tr> <td height=3 colspan=2></td> </tr>",$this->url); */ } } } print " <form method=post>"; print " <div class=well> "; if ($this->email) { printf (_("Email SIP Account information to %s"),$this->email); print " <input type=hidden name=action value=\"send email\"> <button class='btn btn-primary' type=submit> <i class=\"icon-envelope icon-white\"> </i> "; print _("Send"); print "</button>"; } if ($this->sip_settings_page && $this->login_type != 'subscriber') { print "<p>"; printf (_("Login using SIP credentials at <a href=%s>%s</a>"),$this->sip_settings_page,$this->sip_settings_page); print "</p>"; } print $this->hiddenElements; print " </div></form> "; if($this->sip_settings_page) { $this->getbalancehistory(); if (count($this->balance_history) == "0" || $this->login_type != 'subscriber') { print "<form method=post><p>"; print "<input type=hidden name=action value=\"delete account\">"; $date1= new datetime($this->Preferences['account_delete_request']); $today= new datetime('now'); if ($this->Preferences['account_delete_request'] && $this->login_type != 'subscriber' ) { print "<p>User made a deletion request on: "; print $this->Preferences['account_delete_request']; print "</p>"; } if ($date1->diff($today)->d >= '2' || $this->Preferences['account_delete_request'] == '' || $this->login_type != 'subscriber' ) { print '<button data-original-title="'; print _("Delete request"); print "\" data-trigger=\"hover\" data-toggle=\"popover button\" data-content=\""; print " You may request the deletion of your account here. An email confirmation is required to validate the request.\""; print " rel='popover' class='btn btn-warning' type='submit'>"; print _("Delete request"); } else { //print "<button rel='popover' class='btn btn-disabled'disabled type='submit'>"; //printf (_("Account remove request is active")); print "A deletion request has been made on: "; print $this->Preferences['account_delete_request']; } print "</button></p>"; } print $this->hiddenElements; print " </form> "; } }
public function analytics() { $em = $this->getDoctrine()->getManager(); $rep = $em->getRepository('APPAdminBundle:Visite'); $visite = new Visite(); if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } else { $ip = $_SERVER['REMOTE_ADDR']; } $host = gethostbyaddr($ip); $navigateur = $_SERVER['HTTP_USER_AGENT']; $referer = $this->container->get('request')->headers->get('referer'); if (null == $referer) { $referer = ''; } if ($_SERVER['QUERY_STRING'] == "") { $page_courante = $_SERVER['PHP_SELF']; } else { $page_courante = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']; } $visite->setIp($ip); $visite->setHost($host); $visite->setNavigateur($navigateur); $visite->setReferer($referer); $visite->setPage($page_courante); $testIp = $rep->findOneBy(array('ip' => $ip), array('id' => 'desc'), null, null); if (null != $testIp) { $fix = new \datetime(); $newDate = new \datetime($testIp->getDateAjout()->format('Y-m-d h:i:s')); $diff = $fix->diff($newDate); $count = $diff->format('%I'); if ((int) $count > 10) { $visite->setNewSession(1); } else { $visite->setNewSession(0); } } else { $visite->setNewSession(1); } $em->persist($visite); $em->flush(); }