本文整理汇总了PHP中Utils::tps方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::tps方法的具体用法?PHP Utils::tps怎么用?PHP Utils::tps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utils
的用法示例。
在下文中一共展示了Utils::tps方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create($request)
{
if (Session::isActive()) {
$req = $request->getParameters();
$resp = $this->index($request);
if ($req['name'] != '' && $req['channel_id'] != '') {
if (UserChannel::exists($req['channel_id'])) {
if (UserChannel::find($req['channel_id'])->belongToUser(Session::get()->id)) {
if (!Playlist::exists(array('conditions' => array('name = ? AND channel_id = ?', $req['name'], $req['channel_id'])))) {
Playlist::create(array('name' => $req['name'], 'channel_id' => $req['channel_id'], 'videos_ids' => json_encode(array()), 'timestamp' => Utils::tps()));
// Oui cette ligne est dupliquée mais ce n'est pas une erreur, ne pas supprimer SVP
$resp = $this->index($request);
$resp->addMessage(ViewMessage::success('Playlist ajoutée avec succès !'));
} else {
$resp->addMessage(ViewMessage::error('Une playlist du même nom existe déjà sur cette chaîne.'));
}
} else {
$resp->addMessage(ViewMessage::error('Cette chaîne ne vous appartient pas.'));
}
} else {
$resp->addMessage(ViewMessage::error('Cette chaîne n\'existe pas !'));
}
} else {
$resp->addMessage(ViewMessage::error('Merci de remplir tous les champs'));
}
}
return $resp;
}
示例2: create
public function create($request)
{
$req = $request->getParameters();
$response = new ViewResponse('assist/ticket');
if (trim($req['bug']) != '') {
if (Session::isActive()) {
$user_id = Session::get()->id;
} else {
if (trim($req['email']) != '') {
$user_id = $req['email'];
} else {
$user_id = 0;
}
}
if (!empty(Ticket::find('all', ['conditions' => ['ip = ? AND timestamp < ' . (Utils::tps() + 60), $_SERVER['REMOTE_ADDR']]]))) {
$r = $this->index($request);
$r->addMessage(ViewMessage::error('Trop d\'envois avec la même IP en une minute, réssayez plus tard.'));
return $r;
}
$ticket = Ticket::create(array('user_id' => $user_id, 'description' => $req['bug'], 'timestamp' => time(), 'ip' => $_SERVER['REMOTE_ADDR']));
StaffNotification::createNotif('ticket', $user_id, null, $ticket->id);
$ticket_id = $ticket->id;
$response->addMessage(ViewMessage::success('Envoyé ! Vous serez notifié de l\'avancement par E-Mail ou Message Privé (Ticket #' . $ticket_id . ')'));
/*$username = (Session::isActive()) ? Session::get()->username : '[Anonyme]';
$notif = new PushoverNotification();
$notif->setMessage('Nouveau ticket de '.$username);
$notif->setReceiver('all');
$notif->setExtraParameter('url', 'http://dreamvids.fr'.WEBROOT.'admin/tickets');
$notif->send();*/
} else {
$response->addMessage(ViewMessage::error('Merci de nous décrire votre problème.'));
}
return $response;
}
示例3: subscribeUserToChannel
/**
* Add an entry if not already exist into `subscriptions` table that associate a `users` and a `users_channel`
* @param User|int $user
* @param UserChannel|string $channel
*/
public static function subscribeUserToChannel($user, $channel)
{
$user_id = $user instanceof User ? $user->id : $user;
$channel_id = $channel instanceof UserChannel ? $channel->id : $channel;
if (!self::exists(['user_id' => $user_id, 'user_channel_id' => $channel_id])) {
self::create(['user_id' => $user_id, 'user_channel_id' => $channel_id, 'timestamp' => Utils::tps()]);
}
}
示例4: create
public function create($request)
{
$data = $request->getParameters();
if (isset($data['submitLogin']) && !Session::isActive()) {
$is_admin = isset($data['is_admin']) && $data['is_admin'] == 1;
$username = Utils::secure($data['username']);
$password = Utils::secure($data['pass']);
if (User::find_by_username($username)) {
$user = User::find_by_username($username);
$current_log_fail = $user->getLogFails();
if (!$user->isAllowedToAttemptLogin()) {
$next_timestamp = $current_log_fail['next_try'];
$last_try_timestamp = $current_log_fail['last_try'];
$nb_try = $current_log_fail['nb_try'];
$next_try_tps = $next_timestamp - Utils::tps();
$next_try_min = floor($next_try_tps / 60);
$next_try_sec = round($next_try_tps - $next_try_min * 60);
$next_try_str = "{$next_try_min} m et {$next_try_sec} s";
$data = isset($data['redirect']) ? ['redirect' => $data['redirect']] : [];
$data['currentPageTitle'] = 'Connexion';
$response = !$is_admin ? new ViewResponse('login/login', $data) : new ViewResponse('admin/login/login', $data, true, 'layouts/admin_login.php', 401);
$response->addMessage(ViewMessage::error($nb_try . " tentatives de connexions à la suite pour ce compte. Veuillez patienter {$next_try_str}"));
return $response;
}
$realPass = User::find_by_username($username)->getPassword();
if (password_verify($password, $realPass)) {
User::connect($username, 1);
$user->resetLogFails();
return new RedirectResponse($data['redirect'] ? urldecode($data['redirect']) : WEBROOT);
} else {
if (sha1($password) == $realPass) {
$user->resetLogFails();
User::connect($username, 1)->setPassword(password_hash($password, PASSWORD_BCRYPT));
return new RedirectResponse($data['redirect'] ? urldecode($data['redirect']) : WEBROOT);
}
if (!$user->isIntervalBetweenTwoLogAttemptElapsed() || !$current_log_fail) {
$user->addLogFail();
} else {
$user->resetLogFails();
$user->addLogFail();
}
$data = isset($data['redirect']) ? ['redirect' => $data['redirect']] : [];
$data['currentPageTitle'] = 'Connexion';
$response = !$is_admin ? new ViewResponse('login/login', $data) : new ViewResponse('admin/login/login', $data, true, 'layouts/admin_login.php', 401);
$response->addMessage(ViewMessage::error('Mot de passe incorrect'));
return $response;
}
} else {
$data = isset($data['redirect']) ? ['redirect' => $data['redirect']] : [];
$data['currentPageTitle'] = 'Connexion';
$response = !$is_admin ? new ViewResponse('login/login', $data) : new ViewResponse('admin/login/login', $data, true, 'layouts/admin_login.php', 401);
$response->addMessage(ViewMessage::error('Ce nom d\'utilisateur n\'existe pas'));
return $response;
}
}
}
示例5: create
public function create($request)
{
$params = $request->getParameters();
$data = ['success' => false];
$user = Session::get();
if ($params['title'] != '' && $params['content'] != '') {
$new = News::create(['user_id' => $user->id, 'title' => $params['title'], 'content' => $params['content'], 'icon' => $params['icon'], 'level' => $params['level'], 'timestamp' => Utils::tps()]);
$data['success'] = is_object($new);
}
return new JsonResponse($data);
}
示例6: create
public function create($request)
{
$req = $request->getParameters();
$data = [];
$new_question = ['timestamp' => Utils::tps()];
foreach (self::$fields as $field) {
$new_question[$field] = isset($req[$field]) ? $req[$field] : 0;
}
$faq = Faq::create($new_question);
$r = $this->edit($faq->id, $request);
$r->addMessage(ViewMessage::success("Nouvelle Question/Réponse créée. <a href=\"" . WEBROOT . "admin/faq\">Retour à la liste</a>"));
return $r;
}
示例7: init
public static function init()
{
if (isset($_COOKIE['SESSID'])) {
if (UserSession::exists(array('session_id' => $_COOKIE['SESSID']))) {
$session = User::find_by_id(UserSession::find_by_session_id($_COOKIE['SESSID'])->user_id);
session_id($_COOKIE['SESSID']);
self::set($session);
} else {
setcookie("SESSID", "", -1);
self::set(-1);
}
session_start();
}
UserSession::delete_all(array('conditions' => array('expiration < ?', Utils::tps())));
}
示例8: get
public function get($id, $request)
{
if (Session::isActive()) {
Session::get()->last_visit = Utils::tps();
Session::get()->save();
if ($conv = Conversation::find($id)) {
if (!$conv->isUserAllowed(Session::get())) {
return Utils::getUnauthorizedResponse();
}
if ($conv->isTicketConv()) {
$tech['channel'] = $conv->getTechChannel();
$tech['user'] = $conv->getTechUser();
} else {
$tech = null;
}
$messages = $conv->getMessages();
foreach ($messages as $message) {
$sender = UserChannel::exists($message->sender_id) ? UserChannel::find($message->sender_id) : false;
if (is_object($sender)) {
$senderAvatar = $sender->getAvatar();
$pseudo = $sender->name;
if (isset($tech['channel'], $tech['user']) && $sender->id == $tech['channel']->id) {
$pseudo = StaffContact::getShownName($tech['user']);
$senderAvatar = StaffContact::getImageName($tech['user']);
}
$messagesData[] = array('id' => 'id', 'pseudo' => $pseudo, 'channel_name' => $sender->name, 'avatar' => $senderAvatar, 'text' => $message->content, 'mine' => $sender->belongToUser(Session::get()->id));
}
}
$conversationsData = array();
$avatar = $conv->thumbnail;
/*if(!is_array(getimagesize($avatar))) { // if the image is invalid
if(is_array(getimagesize(WEBROOT.$avatar)))
$avatar = WEBROOT.$avatar;
else
$avatar = Config::getValue_('default-avatar');
}*/
//var_dump($conv->isTicketConv());
$conversationsData['infos'] = array('id' => $conv->id, 'title' => $conv->object, 'members' => $conv->getMemberChannelsName(), 'avatar' => $avatar, 'text' => isset(end($messages)->content) ? end($messages)->content : 'Aucun message');
if (isset($messagesData)) {
$conversationsData['messages'] = $messagesData;
}
return new JsonResponse($conversationsData);
}
} else {
return Utils::getUnauthorizedResponse();
}
return new Response(500);
}
示例9: get
public function get($id, $request)
{
if (UserChannel::find($id)->belongToUser(Session::get()->id)) {
$uploadId = Upload::generateId(6);
Upload::create(array('id' => $uploadId, 'channel_id' => $id, 'video_id' => Video::generateId(6), 'expire' => Utils::tps() + 86400));
$data = array();
$data['currentPageTitle'] = 'Mettre en ligne';
$data['uploadId'] = $uploadId;
$data['thumbnail'] = Config::getValue_('default-thumbnail');
$data['channelId'] = $id;
$data['currentPage'] = 'upload';
//$data['predefined_descriptions'] = PredefinedDescription::getDescriptionByChannelsids($id);
return new ViewResponse('upload/upload', $data);
} else {
return new RedirectResponse(WEBROOT . 'upload');
}
}
示例10: sendNew
public static function sendNew($sender, $conversation, $content, $timeOffset = 0)
{
$id = Message::generateId(6);
$timestamp = Utils::tps() + $timeOffset;
$message = Message::create(array('id' => $id, 'sender_id' => $sender, 'conversation_id' => $conversation, 'content' => $content, 'timestamp' => $timestamp));
$recep = array();
$members = explode(';', trim(Conversation::find($conversation)->members_ids, ';'));
foreach ($members as $id) {
if ($id != $sender) {
$recep[] = trim(UserChannel::find($id)->admins_ids, ';');
}
}
$recep = ';' . implode(';', $recep) . ';';
$recep = ChannelAction::filterReceiver($recep, "pm");
ChannelAction::create(array('id' => ChannelAction::generateId(6), 'channel_id' => userChannel::find($sender)->id, 'recipients_ids' => $recep, 'type' => 'pm', 'target' => $conversation, 'timestamp' => $timestamp));
return $message;
}
示例11: getDataForGraph
/**
*
* @param string $class_name
* @param string $timestamp_field
* @param number $long_ago
* @param number $step
* @param string $date_format
* @return array
*/
public static function getDataForGraph($class_name, $timestamp_field = 'timestamp', $long_ago = 2592000, $step = 86400, $date_format = "Y-m-d")
{
$table_name = $class_name::$table_name == '' ? strtolower($class_name) . 's' : $class_name::$table_name;
$min_timestamp = Utils::tps() - $long_ago;
$request = "SELECT DISTINCT time, count(*) AS count FROM (\nSELECT *, ((ROUND(`{$timestamp_field}` / ({$step}))-1)*({$step})) as time FROM `{$table_name}`\nHAVING `{$timestamp_field}` > {$min_timestamp}\nORDER BY {$timestamp_field} DESC) AS temp\nGROUP BY time";
$temp = $class_name::find_by_sql($request);
$result = [];
foreach ($temp as $k => $value) {
$result[date($date_format, $value->time)] = [date($date_format, $value->time), $value->count];
}
foreach (range($min_timestamp, Utils::tps(), $step) as $index => $v) {
$temp_date = date($date_format, $v);
if (!isset($result[$temp_date])) {
$result[$temp_date] = [$temp_date, 0];
}
}
return $result;
}
示例12: index
public function index($request)
{
$data = [];
$data['dv_eggs'] = Eggs::getDreamvidsEggs();
$data['cavi_eggs'] = Eggs::getCaviconEggs();
$now = Utils::tps();
$date_now = new DateTime(date("c", $now));
foreach ($data as $k => $eggs) {
foreach ($eggs as $k2 => $egg) {
if ($egg->show_timestamp < $now) {
$data['intervals'][$egg->id] = '';
} else {
$interval = abs($now - $egg->show_timestamp);
$futur = new DateTime(date("c", $egg->show_timestamp));
$diff = $futur->diff($date_now)->format("%Y ans, %m mois, %d j et %H:%I:%S restant");
$data['intervals'][$egg->id] = $diff;
}
}
}
return new ViewResponse('admin/egg/index', $data);
}
示例13: create
public function create($request)
{
if (Session::isActive()) {
$req = $request->getParameters();
Session::get()->last_visit = Utils::tps();
Session::get()->save();
if (isset($req['sender'], $req['conversation'], $req['content']) && !empty($req['conversation']) && !empty($req['sender']) && !empty($req['content'])) {
$sender = Utils::secure($req['sender']);
$conversation = Utils::secure($req['conversation']);
$content = Utils::secure($req['content']);
$channel = UserChannel::exists($sender) ? UserChannel::find($sender) : false;
if ($channel && $channel->belongToUser(Session::get()->id) && ($conv = Conversation::find($conversation))) {
if (!$conv->containsChannel($channel)) {
return Utils::getUnauthorizedResponse();
}
$message = Message::sendNew($sender, $conversation, $content);
$messageData = array('id' => $message->id, 'avatar' => $channel->getAvatar(), 'pseudo' => $channel->name, 'text' => $content, 'mine' => 'true');
return new JsonResponse($messageData);
}
}
}
return new Response(500);
}
示例14: index
public function index($request)
{
if (Session::isActive()) {
$sess = Session::get();
$data = array();
$data['currentPageTitle'] = 'Flux d\'activité';
$data['actions'] = array();
$data['subscriptions'] = array();
$data['last_visit'] = $sess->last_visit;
$sess->last_visit = Utils::tps();
$sess->save();
$actions = Session::get()->getNotifications();
$data['subscriptions'] = Session::get()->getSubscribedChannels();
if (count($actions) > 0) {
$data['actions'] = $actions;
}
$data = $this->regroupPmFeeds($data);
$data = $this->regroupLikeFeeds($data);
$data = $this->regroupSubscribeFeeds($data);
return new ViewResponse('feed/feed', $data);
} else {
return new RedirectResponse(Utils::generateLoginURL());
}
}
示例15: createNotif
public static function createNotif($type, $id_one = null, $id_two = null, $value = null, $level = '', $viewers = 'team_or_more', $force_push = false)
{
$staff_notif = StaffNotification::create(['type' => $type, 'id_one' => $id_one, 'id_two' => $id_two, 'value' => $value, 'viewers' => $viewers, 'level' => $level, 'timestamp' => Utils::tps()]);
$emails = [];
$title = 'DreamVids';
$sub_title = '';
$is_link = !is_null($staff_notif->getLink());
$link_url = "http://" . @$_SERVER['HTTP_HOST'] . WEBROOT . $staff_notif->getLink();
foreach (User::getTeam() as $user) {
$content = $staff_notif->getContent();
if (Utils::getRankArray($user)[$viewers] && (self::isEnabled($user) || $force_push)) {
if (!is_null($user->details->push_bullet_email) && $user->details->push_bullet_email != '') {
switch ($type) {
case 'ticket_level_change':
$ticket = $staff_notif->getAssociatedValue('Ticket');
$sub_title = 'Tickets';
if (in_array($ticket->ticket_levels_id, $user->getAssignedLevelsIds()) || $user->isAdmin()) {
$emails[] = $user->details->push_bullet_email;
}
break;
case 'ticket':
$sub_title = 'Tickets';
$emails[] = $user->details->push_bullet_email;
break;
case 'news':
$sub_title = 'News';
$emails[] = $user->details->push_bullet_email;
break;
case 'private':
$sub_title = "Message privé";
$content = $staff_notif->value;
if ($staff_notif->id_two == $user->id) {
$emails[] = $user->details->push_bullet_email;
}
break;
case 'private':
$sub_title = "Message";
$content = $staff_notif->value;
$emails[] = $user->details->push_bullet_email;
break;
default:
$emails[] = $user->details->push_bullet_email;
break;
}
}
}
}
$notif = new PushBulletNotification($title . ($sub_title != '' ? ' - ' . $sub_title : ''), $content, $emails, $is_link, $link_url);
$notif->send();
}