/** * Render the div full of chat messages. * @param $chatlength Essentially the limit on the number of messages. **/ function render_chat_messages($chatlength, $show_elipsis = null) { // Eventually there might be a reason to abstract out get_chats(); $sql = new DBAccess(); $sql->Query("SELECT sender_id, uname, message, age(now(), date) as ago FROM chat join players on chat.sender_id = player_id ORDER BY chat_id DESC LIMIT {$chatlength}"); // Pull messages $chats = $sql->fetchAll(); $message_rows = ''; $messageCount = $sql->QueryItem("select count(*) from chat"); if (!isset($show_elipsis) && $messageCount > $chatlength) { $show_elipsis = true; } $res = "<div class='chatMessages'>"; $previous_date = null; $skip_interval = 3; // minutes foreach ($chats as $messageData) { $l_ago = time_ago($messageData['ago'], $previous_date); $message_rows .= "<li><<a href='player.php?player_id={$messageData['sender_id']}'\n\t\t target='main'>{$messageData['uname']}</a>> " . out($messageData['message']) . " <span class='chat-time'>{$l_ago}</span></li>"; $previous_date = $messageData['ago']; // Store just prior date. } $res .= $message_rows; if ($show_elipsis) { // to indicate there are more chats available $res .= ".<br>.<br>.<br>"; } $res .= "</div>"; return $res; }
/** * @link http://css-tricks.com/snippets/php/time-ago-function/ * @param String * @return string */ public function Hace($diahora) { $rcs = 0; $tm = is_int($diahora) ? $diahora : strtotime($diahora); $curTm = time(); $dif = $curTm - $tm; $negativo = false; if ($dif < 0) { $dif = $dif * -1; $negativo = true; } $pds = array('seg', 'min', 'hour', 'day', 'week', 'month', 'year', 'decade'); //$pds = array('segundo', 'minuto', 'hora', 'día', 'semana', 'mes', 'año', 'década'); $lngh = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600); for ($v = sizeof($lngh) - 1; $v >= 0 && ($no = $dif / $lngh[$v]) <= 1; $v--) { } if ($v < 0) { $v = 0; } $_tm = $curTm - $dif % $lngh[$v]; $no = floor($no); if ($no != 1) { $pds[$v] .= substr($pds[$v], -1) == 's' ? 'es' : 's'; } $x = sprintf("%d %s ", $no, $pds[$v]); if ($rcs == 1 && $v >= 1 && $curTm - $_tm > 0) { $x .= time_ago($_tm); } if ($negativo) { return "-" . $x; } return $x; }
function showDate($date) { $stf = 0; $current_time = time(); $diff = $current_time - $date; $seconds = array('секунду', 'секунды', 'секунд'); $minutes = array('минуту', 'минуты', 'минут'); $hours = array('час', 'часа', 'часов'); $days = array('день', 'дня', 'дней'); $weeks = array('неделю', 'недели', 'недель'); $months = array('месяц', 'месяца', 'месяцев'); $years = array('год', 'года', 'лет'); $phrase = array($seconds, $minutes, $hours, $days, $weeks, $months, $years); $length = array(1, 60, 3600, 86400, 604800, 2630880, 31570560); for ($i = sizeof($length) - 1; $i >= 0 && ($no = $diff / $length[$i]) <= 1; $i--) { } if ($i < 0) { $i = 0; } $_time = $current_time - $diff % $length[$i]; $no = floor($no); $value = sprintf("%d %s ", $no, getPhrase($no, $phrase[$i])); if ($stf == 1 && $i >= 1 && $current_time - $_time > 0) { $value .= time_ago($_time); } if (strCaseCmp($value, '1 день ') == 0) { return 'вчера'; } else { return $value . ' назад'; } }
function timeFromPublish($tm, $rcs = 0) { $cur_tm = time(); $dif = $cur_tm - $tm; $lngh = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600); for ($v = sizeof($lngh) - 1; $v >= 0 && ($no = $dif / $lngh[$v]) <= 1; $v--) { } if ($v < 0) { $v = 0; $_tm = $cur_tm - $dif % $lngh[$v]; } $no = floor($no); $useName = $this->timeNames[$v]; if ($no != 1) { if ($useName == "mes") { $useName .= 'es'; } else { $useName .= 's'; } } $x = sprintf("%d %s ", $no, $useName); if ($rcs == 1 && $v >= 1 && $cur_tm - $_tm > 0) { $x .= time_ago($_tm); } return $x; }
/** * @return mixed */ function site_getinfo() { $site = elgg_get_config('site'); $siteinfo['url'] = elgg_get_site_url(); $siteinfo['sitename'] = $site->name; $siteinfo['logo'] = elgg_get_plugin_setting('ws_get_logo', 'elgg_with_rest_api'); if ($site->description == null) { $siteinfo['description'] = ''; } else { $siteinfo['description'] = $site->description; } $siteinfo['time_created'] = time_ago($site->time_created); $siteinfo['language'] = elgg_get_config('language'); return $siteinfo; }
function index() { $h = new History(); $events = $h->include_related('user')->order_by('id DESC')->get_iterated(); foreach ($events as $e) { $message = unserialize($e->message); if (is_string($message)) { $message = $this->messages[$message]; } else { $key = array_shift($message); $message = vsprintf($this->messages[$key], $message); } echo $message . ' by ' . $e->user_username . ' ' . time_ago($e->created_on) . '<br>'; } exit; }
function time_ago($tm, $rcs = 0) { $cur_tm = time(); $dif = $cur_tm - $tm; $pds = array('s', 'm', 'h', 'd', 'w'); $lngh = array(1, 60, 3600, 86400, 604800); for ($v = sizeof($lngh) - 1; $v >= 0 && ($no = $dif / $lngh[$v]) <= 1; $v--) { } if ($v < 0) { $v = 0; } $_tm = $cur_tm - $dif % $lngh[$v]; $x = sprintf("%d%s ", $no, $pds[$v]); if ($rcs == 1 && $v >= 1 && $cur_tm - $_tm > 0) { $x .= time_ago($_tm); } return $x; }
function get_comments($post_id) { $comment = array(); $sql = "SELECT * FROM pb_comments WHERE post_id='{$post_id}'"; $conn = new mysqli(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_NAME); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $result = $conn->query($sql); if ($result->num_rows > 0) { while ($val = $result->fetch_assoc()) { $user_data = json_decode(pb_table_data('pb_users', 'user_data', "user_id='+{$val['author']}'"), true); $item = array('id' => $val['id'], 'date' => $val['date'], 'timestamp' => array('date' => $val['date'], 'laps' => time_ago(strtotime($val['date']))), 'user' => array('id' => $val['author'], 'name' => $user_data[0]['name'], 'username' => $user_data[0]['username'], 'avatar' => $user_data[0]['avatar']), 'status' => $val['status'], 'comment' => $val['comment']); array_push($comment, $item); } } $conn->close(); return json_encode($comment); }
function render_message($message_row, $show_buttons = true, $selected = false) { if (isset($_SESSION["user_id"])) { // set a class based on the readflag $readflag_class = $message_row["ReadFlag"] == 1 ? "read" : ""; $selected_class = $selected ? "selected" : ""; $avatar_image = $message_row["FromUsersAvatar"] != "" ? $message_row["FromUsersAvatar"] : "avatars/generic_64.jpg"; $meta = "<div class=\"avatar\"><a href=\"/" . $message_row["FromUsersUsername"] . "\" title=\"" . $message_row["FromUsersUsername"] . "\"><img src=\"/" . $avatar_image . "\" width=\"32\" height=\"32\" alt=\"" . $message_row["FromUsersUsername"] . "\" /></a></div>\n" . "<div class=\"meta\">\n" . "<div class=\"username\">from <a href=\"/" . $message_row["FromUsersUsername"] . "\" title=\"" . $message_row["FromUsersUsername"] . "\">" . $message_row["FromUsersUsername"] . "</a> to <a href=\"/" . $message_row["ToUsersUsername"] . "\" title=\"" . $message_row["ToUsersUsername"] . "\">" . $message_row["ToUsersUsername"] . "</a></div>\n" . "<div class=\"data\">" . ($message_row["Type"] == 0 ? "<a href=\"/message/" . $message_row["Id"] . "\">" . time_ago($message_row["Created"]) . "</a>" : time_ago($message_row["Created"])) . ($message_row["ParentMessagesId"] != null ? " in response to a <a href=\"/message/" . $message_row["ParentMessagesId"] . "\">message</a> by <a href=\"/" . $message_row["ParentUsersUsername"] . "\">" . $message_row["ParentUsersUsername"] . "</a>" : "") . "</div>\n" . "</div> <!-- .meta -->\n"; // work out the remove button (remove, or restore) $remove_restore_button = ""; if ($message_row["ToUserId"] == $_SESSION["user_id"] && $message_row["ToStatus"] == 0 || $message_row["FromUserId"] == $_SESSION["user_id"] && $message_row["FromStatus"] == 0) { $remove_restore_button = "<div class=\"button\"><a href=\"/api/message/remove/" . $message_row["Id"] . "\" title=\"Remove\" onclick=\"return confirm('Are you sure?');\">Remove</a></div>"; } else { $remove_restore_button = "<div class=\"button\"><a href=\"/api/message/restore/" . $message_row["Id"] . "\" title=\"Restore\" onclick=\"return confirm('Are you sure?');\">Restore</a></div>"; } $html = "<div class=\"message_wrapper\">\n" . "<div class=\"message " . $readflag_class . " " . $selected_class . "\">\n" . "<div class=\"body\">" . Markdown($message_row["Body"]) . "</div>\n" . "<div class=\"info\">\n" . ($show_buttons ? ($message_row["ToUserId"] == $_SESSION["user_id"] && $message_row["Type"] == 0 ? "<div class=\"button\"><a href=\"/messages/compose/" . $message_row["FromUsersUsername"] . "/" . $message_row["Id"] . "/#form\" title=\"Reply\">Reply</a></div>" : "") . $remove_restore_button : "") . $meta . "<div class=\"clear\"></div>\n" . "</div> <!-- .info -->\n" . "</div> <!-- .message -->\n" . "</div> <!-- .message_wrapper -->\n\n"; return $html; } }
function rkv_ago($tm, $rcs = 0) { $cur_tm = time(); $dif = $cur_tm - $tm; $pds = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade'); $lngh = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600); for ($v = sizeof($lngh) - 1; $v >= 0 && ($no = $dif / $lngh[$v]) <= 1; $v--) { } if ($v < 0) { $v = 0; } $_tm = $cur_tm - $dif % $lngh[$v]; $no = floor($no); if ($no != 1) { $pds[$v] .= 's'; } $x = sprintf("%d %s ", $no, $pds[$v]); if ($rcs == 1 && $v >= 1 && $cur_tm - $_tm > 0) { $x .= time_ago($_tm); } return $x; }
/** * Fetches and displays twitter messages * * @example wk_twitter('en', 'TechblogGR', 3, '<h3>Twitter</h3><ul>', '</ul>', '<li>the_twit @ the_time</li>', 60); * * @return The twits * @param string $language * @param string $username * @param int $messages[optional] * @param string $prefix[optional] * @param string $suffix[optional] * @param string $between[optional] Using the vars: the_twit, the_time * @param int $update_time[optional] */ function wk_twitter($language, $username, $messages = 1, $prefix = '', $suffix = '', $between = '', $update_time = 15) { //languages if ($language == 'en') { $ago = 'ago'; } elseif ($language == 'gr') { $ago = 'πριν'; } //include necessary files include_once 'time_ago.php'; //fetch data from database //data in db are saved like that: updated_time . '~' . $alltwits . '~' . $alltimes $data = get_option('wk_twitter'); //seperate to time, twits, times $data = explode('~', $data); $updated_time = $data[0]; //seperate twits $mytwits = explode('|', $data[1]); //seperate times $mytimes = explode('|', $data[2]); //calculate current time $mytime = date('G') * 60 + date('i'); //check if we should update twits if ($mytime > $updated_time + $update_time || $mytime + $update_time < $updated_time) { include_once 'update.php'; wk_twitter_update($username, $messages); } //create final string $final = $prefix; for ($i = 0; $i < $messages; $i++) { //replace dummy vars with the real ones $temp = str_replace('the_twit', $mytwits[$i], $between); $temp = str_replace('the_time', time_ago($mytimes[$i], $language) . " {$ago}", $temp); $final .= $temp; } $final .= $suffix; echo $final; }
function ShowDate($timestamp) { $stf = 0; $cur_time = time(); $diff = $cur_time - $timestamp; $phrase = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade'); $length = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600); for ($i = sizeof($length) - 1; $i >= 0 && ($no = $diff / $length[$i]) <= 1; $i--) { } if ($i < 0) { $i = 0; } $_time = $cur_time - $diff % $length[$i]; $no = floor($no); if ($no != 1) { $phrase[$i] .= 's'; } $value = sprintf("%d %s ", $no, $phrase[$i]); if ($stf == 1 && $i >= 1 && $cur_tm - $_time > 0) { $value .= time_ago($_time); } return $value . ' ago '; }
/** * @link http://css-tricks.com/snippets/php/time-ago-function/ * @param String * @return string */ public static function hace($diahora) { $rcs = 0; $tm = strtotime($diahora); $cur_tm = time(); $dif = $cur_tm - $tm; $pds = array('segundo', 'minuto', 'hora', 'dia', 'semana', 'mes', 'año', 'decada'); $lngh = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600); for ($v = sizeof($lngh) - 1; $v >= 0 && ($no = $dif / $lngh[$v]) <= 1; $v--) { } if ($v < 0) { $v = 0; } $_tm = $cur_tm - $dif % $lngh[$v]; $no = floor($no); if ($no != 1) { $pds[$v] .= substr($pds[$v], -1) == 's' ? 'es' : 's'; } $x = sprintf("%d %s ", $no, $pds[$v]); if ($rcs == 1 && $v >= 1 && $cur_tm - $_tm > 0) { $x .= time_ago($_tm); } return 'hace ' . $x; }
<?php $newscategory = ot_get_option('news-category'); $categorynum = ot_get_option('news-category-num'); $queryObject = new WP_query(array('category__and' => $newscategory, 'posts_per_page' => $categorynum)); if ($queryObject->have_posts()) { while ($queryObject->have_posts()) { $queryObject->the_post(); ?> <li><a href="<?php the_permalink(); ?> "><span><time class="post_date date updated" datetime="<?php the_time('j M, Y'); ?> "><?php echo time_ago(); ?> </time></span> <b class="post-title entry-title"><?php the_title(); ?> </b> </a></li> <?php } } wp_reset_query(); ?> </ul><!-- /ticker --> <?php } elseif (ot_get_option('breaking-or-menu') === '2') { ?> <nav id="mymenutwo">
foreach ($user_data as $data) { $author = $data['name']; $user = $data['username']; $avatar = $data['avatar']; } if (isset($_GET['timeago'])) { $val['date'] = time_ago(strtotime($val['date'])); } $entity = array('id' => $val['id'], 'post_id' => $val['post_id'], 'date' => $val['date'], 'author' => $val['author'], 'user' => array('name' => $author, 'username' => $user, 'avatar' => $avatar), 'status' => $val['status'], 'comment' => $val['comment']); array_push($mainJson, $entity); } // end pb_comments //pb_users if ($slq_table == 'pb_users') { if (isset($_GET['timeago'])) { $val['date'] = time_ago(strtotime($val['date'])); } $entity = array('user_id' => $val['user_id'], 'username' => $val['username'], 'num_of_ratings' => $val['num_of_ratings'], 'total_ratings' => $val['total_ratings'], 'permissions' => $val['permissions'], 'id_card_key' => $val['id_card_key'], 'contact_info' => json_decode($val['contact_info']), 'user_data' => json_decode($val['user_data'])); array_push($mainJson, $entity); } // end pb_users //pb_tags if ($slq_table == 'pb_tags') { $entity = array('id' => $val['tag_id'], 'tag' => $val['tag'], 'count' => $val['count']); array_push($mainJson, $entity); } // end pb_tags //pb_notify if ($slq_table == 'pb_notify') { $entity = array('id' => $val['id'], 'to' => $val['notify_to'], 'from' => $val['notify_from'], 'item' => $val['item'], 'item' => $val['item'], 'intro' => $val['intro'], 'content' => $val['content'], 'link' => $val['link'], 'date' => $val['date'], 'seen' => $val['seen']); array_push($mainJson, $entity);
/** * Created by IntelliJ IDEA. * User: mlui * Date: 2/11/2016 * Time: 4:40 PM */ function album_get_posts($context, $limit = 20, $offset = 0, $username) { if (!$username) { $user = elgg_get_logged_in_user_entity(); throw new InvalidParameterException('registration:usernamenotvalid'); } else { $user = get_user_by_username($username); if (!$user) { throw new InvalidParameterException('registration:usernamenotvalid'); } } $loginUser = elgg_get_logged_in_user_entity(); if ($context == "all") { $params = array('type' => 'object', 'subtype' => 'album', 'owner_guid' => NULL, 'limit' => $limit, 'offset' => $offset, 'full_view' => false, 'list_type' => 'gallery', 'gallery_class' => 'tidypics-gallery'); } else { if ($context == 'mine') { $params = array('type' => 'object', 'subtype' => 'album', 'owner_guid' => $user->guid, 'limit' => $limit, 'offset' => $offset, 'full_view' => false, 'list_type' => 'gallery', 'gallery_class' => 'tidypics-gallery'); } else { if ($context == 'friends') { if ($friends = $user->getFriends(array('limit' => false))) { $friendguids = array(); foreach ($friends as $friend) { $friendguids[] = $friend->getGUID(); } $params = array('type' => 'object', 'subtype' => 'album', 'owner_guids' => $friendguids, 'limit' => $limit, 'offset' => $offset, 'full_view' => false, 'list_type' => 'gallery', 'gallery_class' => 'tidypics-gallery'); } } else { $params = array('type' => 'object', 'subtype' => 'album', 'owner_guid' => NULL, 'limit' => $limit, 'offset' => $offset, 'full_view' => false, 'list_type' => 'gallery', 'gallery_class' => 'tidypics-gallery'); } } } $albums = elgg_get_entities($params); $site_url = get_config('wwwroot'); if ($albums) { $return = array(); foreach ($albums as $single) { $album['guid'] = $single->guid; $album_cover = $single->getCoverImage(); $file_name = $album_cover->getFilenameOnFilestore(); $image_join_date = $album_cover->time_created; $position = strrpos($file_name, '/'); $position = $position + 1; $icon_file_name = substr_replace($file_name, 'smallthumb', $position, 0); $image_icon_url = $site_url . 'services/api/rest/json/?method=image.get_post'; $image_icon_url = $image_icon_url . '&joindate=' . $image_join_date . '&guid=' . $album_cover->guid . '&name=' . $icon_file_name; $image_url = $site_url . 'services/api/rest/json/?method=image.get_post'; $image_url = $image_url . '&joindate=' . $image_join_date . '&guid=' . $album_cover->guid . '&name=' . $file_name; $album['cover_icon_url'] = $image_icon_url; $album['cover_image_url'] = $image_url; if ($single->title != null) { $album['title'] = $single->title; } else { $album['title'] = ''; } $album['time_create'] = time_ago($single->time_created); if ($single->description != null) { if (strlen($single->description) > 300) { $entityString = substr(strip_tags($single->description), 0, 300); $album['description'] = preg_replace('/\\W\\w+\\s*(\\W*)$/', '$1', $entityString) . '...'; } else { $album['description'] = strip_tags($single->description); } } else { $album['description'] = ''; } $owner = get_entity($single->owner_guid); $album['owner']['guid'] = $owner->guid; $album['owner']['name'] = $owner->name; $album['owner']['username'] = $owner->username; $album['owner']['avatar_url'] = getProfileIcon($owner); //$owner->getIconURL('small'); // $photo['img_url'] = $img_url; $album['like_count'] = likes_count_number_of_likes($single->guid); $album['comment_count'] = api_get_image_comment_count($single->guid); $album['like'] = checkLike($single->guid, $loginUser->guid); $return[] = $album; } } else { $msg = elgg_echo('blog:none'); throw new InvalidParameterException($msg); } return $return; }
} } else { ?> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Archived</h3> </div> <div class="panel-body"> <div class="media"> <div class="media-body"> <p> The message has been archived. <abbr title="<?php $archived_str = strtotime($message['archived']); // Tuesday 8:53 AM, Jan 26 2016 echo time_ago($archived_str); ?> "> <?php echo date('l g:i A, M j Y', $archived_str); ?> GMT </abbr> </p> </div> <?php if ($message['type'] != 'campaign') { ?> <div class="media-right"> <a href="<?php
/** * @param $guid * @param $username * @param int $limit * @param int $offset * @return array * @throws InvalidParameterException */ function wire_get_comments($guid, $username, $limit = 20, $offset = 0) { if (!$username) { $user = elgg_get_logged_in_user_entity(); } else { $user = get_user_by_username($username); if (!$user) { throw new InvalidParameterException('registration:usernamenotvalid'); } } $options = array("metadata_name" => "wire_thread", "metadata_value" => $guid, "type" => "object", "subtype" => "thewire", "limit" => $limit, "offset" => $offset); $comments = get_elgg_comments($options, 'elgg_get_entities_from_metadata'); $return = array(); if ($comments) { foreach ($comments as $single) { $comment['guid'] = $single->guid; $comment['description'] = $single->description; $owner = get_entity($single->owner_guid); $comment['owner']['guid'] = $owner->guid; $comment['owner']['name'] = $owner->name; $comment['owner']['username'] = $owner->username; $comment['owner']['avatar_url'] = getProfileIcon($owner); //$owner->getIconURL('small'); $comment['time_created'] = time_ago($single->time_created); $comment['like_count'] = likes_count_number_of_likes($single->guid); $comment['like'] = checkLike($single->guid, $user->guid); $return[] = $comment; } } else { $msg = elgg_echo('generic_comment:none'); throw new InvalidParameterException($msg); } return $return; }
?> role="article"> <header class="article-header"> <figure class="helper-image"> <?php picturefill('dreams-640x400', 'dreams-560x350', 'dreams-480x300'); ?> </figure> </header> <section class="entry-content cf"> <small> <?php single_tag_title(); ?> <i><?php time_ago(); ?> </i> </small> <h2 class="h2 entry-title"> <a href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title_attribute(); ?> "><?php the_title(); ?> </a> </h2>
} // public user } else { $lines[] = ' <tr onmouseover="document.getElementById(\'timeago-' . $userid . '\').style.display = \'block\'" onmouseout="document.getElementById(\'timeago-' . $userid . '\').style.display = \'none\'"><td class="chatter-box"><a href="profile.php?user='******'" class="chatter" title="View ' . $nick . ' Profile"><strong>' . $nick . '</strong></a><br /><span class="timeAgo">' . time_ago($posttime) . '</span></td> <td>' . $shoutx . '<div class="timeago" id="timeago-' . $userid . '" style="display:none;text-align:right;">'; $lines[] = '<span class="label label-success reply-nick" style="font-weight:normal;" onclick="insertNickname(\'@' . $nick . '\')"><i class="icon-retweet icon-white"></i> Reply</span> '; $lines[] = '</div></td></tr> '; } } } // public user } else { $lines[] = ' <tr onmouseover="document.getElementById(\'timeago-' . $userid . '\').style.display = \'block\'" onmouseout="document.getElementById(\'timeago-' . $userid . '\').style.display = \'none\'"><td class="chatter-box"><a href="profile.php?user='******'" class="chatter" title="View ' . $nick . ' Profile"><strong>' . $nick . '</strong></a><br /><span class="timeAgo">' . time_ago($posttime) . '</span></td> <td>' . $shoutx . '<div class="timeago" id="timeago-' . $userid . '" style="display:none;text-align:right;">'; $lines[] = '<span class="label label-success reply-nick" style="font-weight:normal;" onclick="insertNickname(\'@' . $nick . '\')"><i class="icon-retweet icon-white"></i> Reply</span> '; $lines[] = '</div></td></tr> '; } $j++; } echo implode($lines); echo '</tbody></table>'; echo "<div style='padding-top:15px;height:30px'><div style='float:right'>"; if ($show_page > 1 && $show_page < $total_pages) { $olderpage = $show_page + 1; $newerpage = $show_page - 1; $firstpage = 1; $lastpage = $total_pages;
public function get_notification() { $limit = 10; $offset = 0; $level = $this->auth->level_name_by_idlevel(user_admin('level')); $user_reff = NULL; $user_reff_id = NULL; if (in_array($level, array('pm_vendor_manager', 'tt_vendor_manager', 'tt_vendor_helpdesk'))) { $user_reff = 'vendor'; $user_reff_id = user_admin('idvendor'); } $result = $this->model_notification->get_notification($offset, $limit, $user_reff, $user_reff_id); if (count($result) > 0) { echo "<li class='header'>Notifications</li>"; } foreach ($result as $row) { ?> <li> <!-- inner menu: contains the actual data --> <ul class="menu <?php echo $row->status != 'open' ? 'notif-active' : ''; ?> "> <li> <a href="<?php echo site_url('admin/notification/detail/' . $row->uniqid); ?> "> <small class="pull-right" style='padding:3px'><i class="fa fa-clock-o text-warning"></i> <?php echo time_ago($row->datetime, ' '); ?> </small> <i class="fa fa-info-circle info"></i> <?php echo $row->message; ?> </a> </li> </ul> </li> <?php } if (count($result) <= 0) { echo '<center style="padding:20px;"> <div class="fa fa-bell fa-5x " style="color:#ccc"></div> <div class="text-mute" style="color:#ccc">No Notification</div> </center>'; } else { echo "<li class='footer'><a href='" . site_url('admin/notification') . "'>View All</a></li>"; } }
function ajax_comment() { global $wpdb; //nocache_headers(); $comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0; $post = get_post($comment_post_ID); $post_author = $post->post_author; if (empty($post->comment_status)) { do_action('comment_id_not_found', $comment_post_ID); ajax_comment_err(__('Invalid comment status.', 'Lophita')); } $status = get_post_status($post); $status_obj = get_post_status_object($status); if (!comments_open($comment_post_ID)) { do_action('comment_closed', $comment_post_ID); ajax_comment_err(__('Sorry, comments are closed for this item.', 'Lophita')); } elseif ('trash' == $status) { do_action('comment_on_trash', $comment_post_ID); ajax_comment_err(__('Invalid comment status.', 'Lophita')); } elseif (!$status_obj->public && !$status_obj->private) { do_action('comment_on_draft', $comment_post_ID); ajax_comment_err(__('Invalid comment status.', 'Lophita')); } elseif (post_password_required($comment_post_ID)) { do_action('comment_on_password_protected', $comment_post_ID); ajax_comment_err(__('Password Protected', 'Lophita')); } else { do_action('pre_comment_on_post', $comment_post_ID); } $comment_author = isset($_POST['author']) ? trim(strip_tags($_POST['author'])) : null; $comment_author_email = isset($_POST['email']) ? trim($_POST['email']) : null; $comment_author_url = isset($_POST['url']) ? trim($_POST['url']) : null; $comment_content = isset($_POST['comment']) ? trim($_POST['comment']) : null; $edit_id = isset($_POST['edit_id']) ? $_POST['edit_id'] : null; $user = wp_get_current_user(); if ($user->exists()) { if (empty($user->display_name)) { $user->display_name = $user->user_login; } $comment_author = $wpdb->escape($user->display_name); $comment_author_email = $wpdb->escape($user->user_email); $comment_author_url = $wpdb->escape($user->user_url); $user_ID = $wpdb->escape($user->ID); if (current_user_can('unfiltered_html')) { if (wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment']) { kses_remove_filters(); kses_init_filters(); } } } else { if (get_option('comment_registration') || 'private' == $status) { ajax_comment_err(__('Sorry, you must be logged in to post a comment.', 'Lophita')); } } $comment_type = ''; if (get_option('require_name_email') && !$user->exists()) { if (6 > strlen($comment_author_email) || '' == $comment_author) { ajax_comment_err(__('Error: please fill the required fields (name, email).', 'Lophita')); } elseif (!is_email($comment_author_email)) { ajax_comment_err(__('Error: please enter a valid email address.', 'Lophita')); } } if ('' == $comment_content) { ajax_comment_err(__('Error: please type a comment.', 'Lophita')); } $dupe = "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = '{$comment_post_ID}' AND ( comment_author = '{$comment_author}' "; if ($comment_author_email) { $dupe .= "OR comment_author_email = '{$comment_author_email}' "; } $dupe .= ") AND comment_content = '{$comment_content}' LIMIT 1"; if ($wpdb->get_var($dupe)) { ajax_comment_err(__('Duplicate comment detected; it looks as though you’ve already said that!', 'Lophita')); } if ($lasttime = $wpdb->get_var($wpdb->prepare("SELECT comment_date_gmt FROM {$wpdb->comments} WHERE comment_author = %s ORDER BY comment_date DESC LIMIT 1", $comment_author))) { $time_lastcomment = mysql2date('U', $lasttime, false); $time_newcomment = mysql2date('U', current_time('mysql', 1), false); $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment); if ($flood_die) { ajax_comment_err(__('You are posting comments too quickly. Slow down.', 'Lophita')); } } $comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0; $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID'); if ($edit_id) { $comment_id = $commentdata['comment_ID'] = $edit_id; if (ihacklog_user_can_edit_comment($commentdata, $comment_id)) { wp_update_comment($commentdata); } else { ajax_comment_err(__('Cheatin’ uh?', 'Lophita')); } } else { $comment_id = wp_new_comment($commentdata); } $comment = get_comment($comment_id); do_action('set_comment_cookies', $comment, $user); $comment_depth = 1; $tmp_c = $comment; while ($tmp_c->comment_parent != 0) { $comment_depth++; $tmp_c = get_comment($tmp_c->comment_parent); } $GLOBALS['comment'] = $comment; ?> <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?> "> <article id="comment-<?php comment_ID(); ?> " class="comment-container"> <div class="comment-header"> <span class="comment-name"><?php printf(__('%s'), get_comment_author_link()); ?> </span> <time class="comment-date" datetime="<?php comment_time('Y/m/d H:i:s'); ?> "><?php echo time_ago(); ?> </time> </div> <?php if ('0' == $comment->comment_approved) { ?> <p class="comment-awaiting-moderation">您的评论正在排队等待审核,请稍后再来!</p> <?php } ?> <div class="comment-content"> <?php comment_text(); ?> </div> </article> <?php die; }
echo group_name($dc['GUID'], 'GROUP_NAME'); ?> </td> <td class="text-center"><?php echo $dc['ISLOGIN'] == 0 ? "No" : "Logged"; ?> </td> <td class="text-center"><?php echo $dc['VERIFIED'] == 0 ? "No" : "Verified"; ?> </td> <td class="text-center" title="<?php echo $dc['LASTLOGIN']; ?> "><?php echo time_ago($dc['LASTLOGIN']); ?> </td> <td class="text-center"> <a type="button" class="btn btn-xs btn-primary" href="?p=user&act=edit&guid=<?php echo $dc['GUID']; ?> ">Edit</a> <a type="button" class="btn btn-xs btn-danger" href="?p=user&act=delete&guid=<?php echo $dc['GUID']; ?> " <?php echo yakin(); ?> >Delete</a> </td>
?> "><?php the_title(); ?> </a></h4> <p class="byline"> Published <time datetime="<?php the_time('Y-m-d'); ?> " title="<?php the_time('F j, Y'); ?> "> <?php echo time_ago(get_the_time('U')); ?> </time> </p> <?php the_excerpt(); ?> </article> <?php } wp_reset_postdata(); ?> </div>
<div class="post-meta"> <time datetime="<?php echo get_post_time('c', true); ?> "><?php echo time_ago(get_the_date()); ?> </time> <span class="byline author vcard"><em style="text-transform: none"><?php echo __('by', 'sage'); ?> </em> <a href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?> " rel="author" class="fn"><?php echo get_the_author(); ?> </a></span> </div>
public function toArray() { $array = parent::toArray(); // small modifications $array['unixtime'] = strtotime($array['created_at']); $array['edited'] = strtotime($array['updated_at']); $array['timeago'] = time_ago($array['created_at']); $array['time'] = modding_link(rtrim($array['time'])); $array['text'] = linkify(modding_link($array['text'])); $array['icon'] = $array['is_resolved'] ? $this->icons['resolved'] : (@$this->icons[$array['type']] ?: ''); // renames $array['id'] = $array['item_id']; $array['beatmap'] = $array['beatmap_id']; $array['resolved'] = $array['is_resolved']; // unsets unset($array['item_id']); unset($array['beatmapset_id']); unset($array['beatmap_id']); unset($array['is_resolved']); unset($array['created_at']); unset($array['updated_at']); if (!$array['deleted_at']) { unset($array['deleted_at']); } return $array; }
</a> </h3> <div class="entry-song-detail"> <span style="font-weight:bold">Artist: </span> <a href="<?php echo base_url('search?q=' . str_replace(' ', '+', $songArtist)); ?> " title="More songs by <?php echo $songArtist; ?> "><?php echo $songArtist; ?> </a> | Uploaded <?php echo time_ago($song->published_date); ?> by <a href="<?php echo base_url('u/' . $song->username); ?> " title="View <?php echo $song->username; ?> 's Profile" rel="nofollow"><?php echo $song->username; ?> </a> <?php if ($this->ion_auth->in_group('verified', $song->user_id)) { ?>
?> "> <?php } else { ?> <i class="fa fa-rocket"></i> <?php } ?> </div> <div class="comment-content"> <h5><?php echo $value->subject; ?> </h5> <p><small class="text-muted"><span class="datetime"> <i class="glyphicon glyphicon-time"></i> <?php echo time_ago($value->datetime, true); /*date($core_settings->date_format.' '.$core_settings->date_time_format, $value->datetime);*/ ?> </span></small></p> <p><?php echo character_limiter(strip_tags($value->message), 25); ?> </p> </div> </li> <?php $i = $i + 1; if ($i == 5) { break; } }
if (!$DB->has_results()) { error(404); } list($UploaderID, $UploadTime, $TorrentReleaseType, $Bitrate, $Format, $Media, $HasLog, $HasCue, $LogScore, $TorrentCategoryID, $TorrentCatalogueNumber) = $DB->next_record(); $FillerID = $LoggedUser['ID']; $FillerUsername = $LoggedUser['Username']; if (!empty($_POST['user']) && check_perms('site_moderate_requests')) { $FillerUsername = $_POST['user']; $DB->query("\n\t\tSELECT ID\n\t\tFROM users_main\n\t\tWHERE Username LIKE '" . db_string($FillerUsername) . "'"); if (!$DB->has_results()) { $Err = 'No such user to fill for!'; } else { list($FillerID) = $DB->next_record(); } } if (time_ago($UploadTime) < 3600 && $UploaderID !== $FillerID && !check_perms('site_moderate_requests')) { $Err = 'There is a one hour grace period for new uploads to allow the torrent\'s uploader to fill the request.'; } $DB->query("\n\tSELECT\n\t\tTitle,\n\t\tUserID,\n\t\tTorrentID,\n\t\tCategoryID,\n\t\tReleaseType,\n\t\tCatalogueNumber,\n\t\tBitrateList,\n\t\tFormatList,\n\t\tMediaList,\n\t\tLogCue\n\tFROM requests\n\tWHERE ID = {$RequestID}"); list($Title, $RequesterID, $OldTorrentID, $RequestCategoryID, $RequestReleaseType, $RequestCatalogueNumber, $BitrateList, $FormatList, $MediaList, $LogCue) = $DB->next_record(); if (!empty($OldTorrentID)) { $Err = 'This request has already been filled.'; } if ($RequestCategoryID !== '0' && $TorrentCategoryID !== $RequestCategoryID) { $Err = 'This torrent is of a different category than the request. If the request is actually miscategorized, please contact staff.'; } $CategoryName = $Categories[$RequestCategoryID - 1]; if ($CategoryName === 'Music') { //Commenting out as it's causing some issues with some users being unable to fill, unsure what it is, etc /*if ($RequestCatalogueNumber) { if ($TorrentCatalogueNumber !== $RequestCatalogueNumber) {
/** * @ http://us.php.net/manual/en/function.time.php#71342 */ function time_ago($timestamp, $recursive = 0) { $current_time = time(); $difference = $current_time - $timestamp; $periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade"); $lengths = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600); for ($val = sizeof($lengths) - 1; $val >= 0 && ($number = $difference / $lengths[$val]) <= 1; $val--) { } if ($val < 0) { $val = 0; } $new_time = $current_time - $difference % $lengths[$val]; $number = floor($number); if ($number != 1) { $periods[$val] .= "s"; } $text = sprintf("%d %s ", $number, $periods[$val]); if ($recursive == 1 && $val >= 1 && $current_time - $new_time > 0) { $text .= time_ago($new_time); } return $text; }