function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $twitter_username = $instance['twitter_username']; $show_num = $instance['show_num']; $consumer_key = $instance['consumer_key']; $consumer_secret = $instance['consumer_secret']; $access_token = $instance['access_token']; $access_token_secret = $instance['access_token_secret']; $cache_time = $instance['cache_time']; // Opening of widget echo $before_widget; // Open of title tag if ($title) { echo $before_title . $title . $after_title; } $last_cache_time = get_option('gdl_twitter_widget_last_cache_time', 0); $diff = time() - $last_cache_time; $crt = $cache_time * 3600; if (empty($last_cache_time) || $diff >= $crt) { $connection = getConnectionWithAccessToken($consumer_key, $consumer_secret, $access_token, $access_token_secret); $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $twitter_username . "&count=" . $show_num) or die('Couldn\'t retrieve tweets! Wrong username?'); if (!empty($tweets->errors)) { if ($tweets->errors[0]->message == 'Invalid or expired token') { echo '<strong>' . $tweets->errors[0]->message . '!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget; } else { echo '<strong>' . $tweets->errors[0]->message . '</strong>' . $after_widget; } return; } $tweets_data = array(); for ($i = 0; $i <= count($tweets); $i++) { if (!empty($tweets[$i])) { $tweets_data[$i]['created_at'] = $tweets[$i]->created_at; $tweets_data[$i]['text'] = $tweets[$i]->text; $tweets_data[$i]['status_id'] = $tweets[$i]->id_str; } } update_option('gdl_twitter_widget_tweets', serialize($tweets_data)); update_option('gdl_twitter_widget_last_cache_time', time()); } else { $tweets_data = maybe_unserialize(get_option('gdl_twitter_widget_tweets')); } echo '<div class="twitter-whole">'; echo '<ul id="twitter_update_list">'; foreach ($tweets_data as $each_tweet) { echo '<li>'; echo '<span>' . convert_links($each_tweet['text']) . '</span>'; echo '<a target="_blank" href="http://twitter.com/' . $twitter_username . '/statuses/' . $each_tweet['status_id'] . '">' . relative_time($each_tweet['created_at']) . '</a>'; echo '</li>'; } echo '</ul>'; echo '</div>'; // Closing of widget echo $after_widget; }
public function Execute(Template $template, Session $session, $request) { // view a member's profile if (isset($request['id'])) { $id = intval($request['id']); /* Chck if we're trying to look at the gues user */ if ($id == 0) { return new Error($template['L_USERDOESNTEXIST'], $template); } /* Get our user from the db */ $user = DBA::Open()->GetRow("SELECT * FROM " . USERS . " WHERE id = {$id}"); /* If our user has admin perms, use a different tamplate */ if ($session['user']['perms'] & ADMIN) { $template->content = array('file' => 'admin/member.html'); } else { $template->content = array('file' => 'member.html'); } /* set the user info template variables */ $template['id'] = $user['id']; $template['name'] = $user['name']; $template['email'] = $user['email']; $template['posts'] = $user['posts']; $template['created'] = relative_time($user['created']); $template['rank'] = $user['rank']; if ($template['displayemails'] == 1) { $template->email_link = array('hide' => TRUE); } else { if ($template['displayemails'] == 0) { $template->email_address = array('hide' => TRUE); } } /* Set the last seen time */ $user['seen'] = $user['seen'] == 0 ? time() : $user['seen']; $user['last_seen'] = $user['last_seen'] == 0 ? time() : $user['last_seen']; $template['seen'] = $user['seen'] >= time() - Lib::GetSetting('sess.gc_maxlifetime') ? relative_time($user['seen']) : relative_time($user['last_seen']); /* Set the user's online status field on the template */ if ($user['seen'] >= time() - Lib::GetSetting('sess.gc_maxlifetime')) { $template['online_status'] = $template['L_ONLINE']; } else { $template['online_status'] = $template['L_OFFLINE']; } } /* Set the number of queries */ $template['num_queries'] = $session->dba->num_queries; return TRUE; }
public function widget($args, $instance) { extract($args); if (!empty($instance['title'])) { $title = apply_filters('widget_title', $instance['title']); } echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } //check settings and die if not set if (empty($instance['consumerkey']) || empty($instance['consumersecret']) || empty($instance['accesstoken']) || empty($instance['accesstokensecret']) || empty($instance['cachetime']) || empty($instance['username'])) { echo '<strong>Please fill all widget settings!</strong>' . $after_widget; return; } //check if cache needs update $tp_twitter_plugin_last_cache_time = get_option('tp_twitter_plugin_last_cache_time'); $diff = time() - $tp_twitter_plugin_last_cache_time; $crt = $instance['cachetime'] * 3600; // yes, it needs update if ($diff >= $crt || empty($tp_twitter_plugin_last_cache_time)) { if (!class_exists('TwitterOAuth')) { if (!(require_once TEMPLATEPATH . '/widgets/twitter/twitteroauth.php')) { echo '<strong>Couldn\'t find twitteroauth.php!</strong>' . $after_widget; return; } } function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) { $connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret); return $connection; } $connection = getConnectionWithAccessToken($instance['consumerkey'], $instance['consumersecret'], $instance['accesstoken'], $instance['accesstokensecret']); $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $instance['username'] . "&count=10") or die('Couldn\'t retrieve tweets! Wrong username?'); if (!empty($tweets->errors)) { if ($tweets->errors[0]->message == 'Invalid or expired token') { echo '<strong>' . $tweets->errors[0]->message . '!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget; } else { echo '<strong>' . $tweets->errors[0]->message . '</strong>' . $after_widget; } return; } for ($i = 0; $i <= count($tweets); $i++) { if (!empty($tweets[$i])) { $tweets_array[$i]['created_at'] = $tweets[$i]->created_at; $tweets_array[$i]['text'] = $tweets[$i]->text; $tweets_array[$i]['status_id'] = $tweets[$i]->id_str; } } //save tweets to wp option update_option('tp_twitter_plugin_tweets', serialize($tweets_array)); update_option('tp_twitter_plugin_last_cache_time', time()); echo '<!-- twitter cache has been updated! -->'; } //convert links to clickable format function convert_links($status, $targetBlank = true, $linkMaxLen = 250) { // the target $target = $targetBlank ? " target=\"_blank\" " : ""; // convert link to url $status = preg_replace("/((http:\\/\\/|https:\\/\\/)[^ )\n]+)/e", "'<a href=\"\$1\" title=\"\$1\" {$target} >'. ((strlen('\$1')>={$linkMaxLen} ? substr('\$1',0,{$linkMaxLen}).'...':'\$1')).'</a>'", $status); // convert @ to follow $status = preg_replace("/(@([_a-z0-9\\-]+))/i", "<a href=\"http://twitter.com/\$2\" title=\"Follow \$2\" {$target} >\$1</a>", $status); // convert # to search $status = preg_replace("/(#([_a-z0-9\\-]+))/i", "<a href=\"https://twitter.com/search?q=\$2\" title=\"Search \$1\" {$target} >\$1</a>", $status); // return the status return $status; } //convert dates to readable format function relative_time($a) { //get current timestampt $b = strtotime("now"); //get timestamp when tweet created $c = strtotime($a); //get difference $d = $b - $c; //calculate different time values $minute = 60; $hour = $minute * 60; $day = $hour * 24; $week = $day * 7; if (is_numeric($d) && $d > 0) { //if less then 3 seconds if ($d < 3) { return "right now"; } //if less then minute if ($d < $minute) { return floor($d) . " seconds ago"; } //if less then 2 minutes if ($d < $minute * 2) { return "about 1 minute ago"; } //if less then hour if ($d < $hour) { return floor($d / $minute) . " minutes ago"; } //if less then 2 hours if ($d < $hour * 2) { return "about 1 hour ago"; } //if less then day if ($d < $day) { return floor($d / $hour) . " hours ago"; } //if more then day, but less then 2 days if ($d > $day && $d < $day * 2) { return "yesterday"; } //if less then year if ($d < $day * 365) { return floor($d / $day) . " days ago"; } //else return more than a year return "over a year ago"; } } $tp_twitter_plugin_tweets = maybe_unserialize(get_option('tp_twitter_plugin_tweets')); if (!empty($tp_twitter_plugin_tweets)) { //print '<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="http://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>'; print '<script>jQuery(window).load(function () { jQuery.getScript(\'http://platform.twitter.com/widgets.js\'); });</script>'; print '<div class="twitter-feed">'; print '<div class="tweets" id="twitterFeed">'; $fctr = '1'; if (is_array($tp_twitter_plugin_tweets)) { foreach ($tp_twitter_plugin_tweets as $tweet) { print '<div><a class="twTime" target="_blank" href="http://twitter.com/' . $instance['username'] . '/statuses/' . $tweet['status_id'] . '"><span>' . relative_time($tweet['created_at']) . '</span></a>' . convert_links($tweet['text']) . '</div>'; if ($fctr == $instance['tweetstoshow']) { break; } $fctr++; } } print '</div>'; print '<a href="https://twitter.com/' . $instance['username'] . '" class="twitter-follow-button" data-show-count="false">Follow @' . $instance['username'] . '</a>'; print '</div><!-- end twitter-feed -->'; // print ' // <div class="tp_recent_tweets"> // <ul>'; // $fctr = '1'; // foreach($tp_twitter_plugin_tweets as $tweet){ // print '<li><span>'.convert_links($tweet['text']).'</span><br /><a class="twitter_time" target="_blank" href="http://twitter.com/'.$instance['username'].'/statuses/'.$tweet['status_id'].'">'.relative_time($tweet['created_at']).'</a></li>'; // if($fctr == $instance['tweetstoshow']){ break; } // $fctr++; // } // print ' // </ul> // </div>'; } echo $after_widget; }
} $fetchid = $row['report_about']; if (check_if_guest($fetchid)) { $sql = get_guest_details($fetchid); $result2 = $db->execute($sql); $user = $db->fetch_array($result2); $about_name = create_guest_username($user['userid'], $user['guest_name']); $about_avatar = $base_url . AC_FOLDER_ADMIN . "/images/img-no-avatar.gif"; } else { $sql = get_user_details($fetchid); $result3 = $db->execute($sql); $user = $db->fetch_array($result3); $about_name = $user['username']; $about_avatar = get_avatar($user['avatar'], $fetchid); } $reports[] = array('id' => $row['id'], 'from' => $from_name, 'from_pic' => $from_avatar, 'about' => $about_name, 'about_pic' => $about_avatar, 'time' => relative_time($row['report_time']), 'about_num' => $row['COUNT(id)']); } $result = $db->execute("\n\t\t\tSELECT COUNT(id)\n\t\t\tFROM arrowchat_reports\n\t\t\tWHERE (working_time < (" . time() . " - 600)\n\t\t\t\t\t\tOR working_by = '" . $db->escape_string($userid) . "')\n\t\t\t\tAND completed_time = 0\n\t\t"); if ($row = $db->fetch_array($result)) { $total_reports = $row['COUNT(id)']; } else { $total_reports = 0; } $response['total_reports'] = array('count' => $total_reports); $response['reports'] = $reports; } else { echo 1; close_session(); exit; } header('Content-type: application/json; charset=UTF-8');
</a></span></td> <td><span<?php echo strlen($page->uri) > $l ? ' class="tipW" title="' . $page->uri . '"' : ""; ?> ><a href="<?php echo site_url($page->uri); ?> " class="highlightLink"><?php echo ellipsize($page->uri, $l, 0.5); ?> </a></span><span style="display: none;"><?php echo $page->uri; ?> </span></td> <td class="center"><?php echo empty($rep->updated) ? "—" : '<span class="tipN" title="' . date(Setting::value('datetime_format', 'F j, Y @ H:i'), $rep->updated) . '">' . relative_time($rep->updated) . '</span> ' . __('by %s', User::factory($rep->editor_id)->name); ?> </td> <td class="center"><?php $fnd = $rep->repeatableitem->get()->result_count(); echo $fnd; ?> item<?php echo $fnd != 1 ? 's' : ''; ?> found</td> <td class="actBtns"> <a title="Edit" href="<?php echo site_url('administration/contents/edit/' . $rep->id . '/' . $rep->div); ?> " class="tipN"><img src="<?php
?> </h1> <?php if (count(Feeds::get_instance()->getAll()) === 0) { ?> <p><?php _e("Firstly, thanks for using Lilina! To help you settle in, we've included a few nifty tools in Lilina, just to help you get started."); ?> </p> <?php } else { $updated = get_option('last_updated'); if (!$updated) { $message = sprintf(_r('You currently have %d items in %d feeds. Never updated.', count(Items::get_instance()->get_items()), count(Feeds::get_instance()->getAll()))); } else { $message = sprintf(_r('You currently have %d items in %d feeds. Last updated %s.'), count(Items::get_instance()->get_items()), count(Feeds::get_instance()->getAll()), relative_time($updated)); } ?> <p><?php echo $message; ?> </p> <?php } ?> <h2><?php _e('Import'); ?> </h2> <p><?php _e("We can import from any service which supports an open standard called OPML. Here's some services you can import from:");
?> </a> <?php } else { ?> <?php echo $row['title']; } ?> </h2> <p class="article-info"> <span class="date" title="<?php echo date("d/m/Y \\a \\l\\e\\s H:i:s", strtotime($row['date'])); ?> "><?php echo relative_time(strtotime($row['date'])); ?> </span> </p> <div class="article-content"> <?php if ($row['image'] != NULL) { ?> <img class="article-image" src="/images/news/<?php echo $row['fansub_id']; ?> /<?php echo $row['image']; ?> " alt=""/> <?php
<?php $content = Content::factory()->where('div', $div_id)->group_start()->where_related_page('id', $page->id)->or_where('is_global', true)->group_end()->limit(1)->get(); ?> <tr data-rel="<?php echo $content->exists() ? $content->id : 0; ?> " class="grade<?php echo !$content->exists() ? 'X' : (!empty($content->is_global) ? 'C' : 'A'); ?> "> <td class="center"><?php echo $div_id; ?> </td> <td class="center"><?php echo !$content->exists() ? "—" : '<span class="tipN" title="' . date(Setting::value('datetime_format', 'F j, Y @ H:i'), $content->updated == 0 ? $content->created : $content->updated) . '">' . relative_time($content->updated == 0 ? $content->created : $content->updated) . '</span> ' . __('by %s', User::factory($content->editor_id)->name); ?> </td> <td class="actBtns"> <a title="Edit" href="<?php echo $content->exists() ? site_url('administration/contents/edit/' . $content->id . '/' . $div_id) : site_url('administration/contents/add/' . $page->id . '/' . $div_id); ?> " class="tipN"><img src="<?php echo $template->base_url(); ?> images/icons/dark/pencil.png" alt=""></a> <a title="Remove" onclick="remove_content(<?php echo $content->exists() ? $content->id : 0; ?> , '<?php echo str_replace("'", "`", $content->exists() ? $content->div : 'undefined');
public function widget($args, $instance) { extract($args); if (!empty($instance['title'])) { $title = apply_filters('widget_title', $instance['title']); } echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } if (empty($instance['consumerkey']) || empty($instance['consumersecret']) || empty($instance['accesstoken']) || empty($instance['accesstokensecret']) || empty($instance['cachetime']) || empty($instance['username'])) { echo '<strong>Please fill all widget settings!</strong>' . $after_widget; return; } // Check cache time $tc_recent_tweets_cache_time = get_option('tc_recent_tweets_cache_time'); $diff = time() - $tc_recent_tweets_cache_time; $crt = $instance['cachetime'] * 3600; //require_once('twitteroauth.php'); if ($diff >= $crt || empty($tc_recent_tweets_cache_time)) { if (!(require_once 'twitteroauth.php')) { echo '<strong>Couldn\'t find twitteroauth.php!</strong>' . $after_widget; return; } function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) { $connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret); return $connection; } $connection = getConnectionWithAccessToken($instance['consumerkey'], $instance['consumersecret'], $instance['accesstoken'], $instance['accesstokensecret']); $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $instance['username'] . "&count=10") or die('Couldn\'t retrieve tweets! Wrong username?'); if (!empty($tweets->errors)) { if ($tweets->errors[0]->message == 'Invalid or expired token') { echo '<strong>' . $tweets->errors[0]->message . '!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget; } else { echo '<strong>' . $tweets->errors[0]->message . '</strong>' . $after_widget; } return; } for ($i = 0; $i <= count($tweets); $i++) { if (!empty($tweets[$i])) { $tweets_array[$i]['created_at'] = $tweets[$i]->created_at; $tweets_array[$i]['text'] = $tweets[$i]->text; $tweets_array[$i]['status_id'] = $tweets[$i]->id_str; } } //save tweets to wp option update_option('mts_twitter_plugin_tweets', serialize($tweets_array)); update_option('tc_recent_tweets_cache_time', time()); echo '<!-- twitter cache has been updated! -->'; } //convert links to clickable format function convert_links($status, $targetBlank = true, $linkMaxLen = 250) { $target = $targetBlank ? " target=\"_blank\" " : ""; // the target $status = preg_replace("/((http:\\/\\/|https:\\/\\/)[^ )]+)/e", "'<a href=\"\$1\" title=\"\$1\" {$target} >'. ((strlen('\$1')>={$linkMaxLen} ? substr('\$1',0,{$linkMaxLen}).'...':'\$1')).'</a>'", $status); // convert link to url $status = preg_replace("/(@([_a-z0-9\\-]+))/i", "<a href=\"http://twitter.com/\$2\" title=\"Follow \$2\" {$target} >\$1</a>", $status); // convert @ to follow $status = preg_replace("/(#([_a-z0-9\\-]+))/i", "<a href=\"https://twitter.com/search?q=\$2\" title=\"Search \$1\" {$target} >\$1</a>", $status); // convert # to search return $status; // return the status } //convert dates to readable format function relative_time($a) { $b = strtotime("now"); //get current timestampt $c = strtotime($a); //get timestamp when tweet created $d = $b - $c; //get difference $minute = 60; //calculate different time values $hour = $minute * 60; $day = $hour * 24; $week = $day * 7; if (is_numeric($d) && $d > 0) { if ($d < 3) { return "right now"; } //if less then 3 seconds if ($d < $minute) { return floor($d) . " seconds ago"; } //if less then minute if ($d < $minute * 2) { return "about 1 minute ago"; } //if less then 2 minutes if ($d < $hour) { return floor($d / $minute) . " minutes ago"; } //if less then hour if ($d < $hour * 2) { return "about 1 hour ago"; } //if less then 2 hours if ($d < $day) { return floor($d / $hour) . " hours ago"; } //if less then day if ($d > $day && $d < $day * 2) { return "yesterday"; } //if more then day, but less then 2 days if ($d < $day * 365) { return floor($d / $day) . " days ago"; } //if less then year return "over a year ago"; //else return more than a year } } $mts_twitter_plugin_tweets = maybe_unserialize(get_option('mts_twitter_plugin_tweets')); if (!empty($mts_twitter_plugin_tweets)) { print '<div class="tc-recent-tweets tweets"><ul>'; $fctr = '1'; foreach ($mts_twitter_plugin_tweets as $tweet) { print '<li><span>' . convert_links($tweet['text']) . '</span><br /><a class="twitter-time" target="_blank" href="http://twitter.com/' . $instance['username'] . '/statuses/' . $tweet['status_id'] . '">' . relative_time($tweet['created_at']) . '</a></li>'; if ($fctr == $instance['tweetstoshow']) { break; } $fctr++; } print '</ul></div>'; } echo $after_widget; }
<?php if (isset($activities) && is_array($activities) && count($activities)) { ?> <ul class="clean"> <?php foreach ($activities as $activity) { ?> <?php $identity = $this->settings_lib->item('auth.login_type') == 'email' ? $activity->email : $activity->username; ?> <li> <span class="small"><?php echo relative_time(strtotime($activity->created_on)); ?> </span> <br/> <b><?php e($identity); ?> </b> <?php echo $activity->activity; ?> </li> <?php } ?> </ul> <?php
<div class="notification attention"> <p><?php echo isset($update_message) ? $update_message : 'Update Checks are turned off in the config/application.php file.' ?></p> </div> <?php if (isset($commits) && is_array($commits) && count($commits)) : ?> <h3>New Bleeding Edge Commits</h3> <table> <thead> <tr> <th>Author</th> <th style="width: 8em">Committed</th> <th>Message</th> </tr> </thead> <tbody> <?php foreach ($commits as $commit) : ?> <?php if ($commit->id > config_item('updates.last_commit')) :?> <tr> <td><?php echo anchor('http://github.com/'. $commit->author->name, $commit->author->name, array('target' => '_blank')) ?></td> <td><?php echo relative_time(strtotime($commit->committed_date)) ?></td> <td><?php echo $commit->message ?></td> </tr> <?php endif; ?> <?php endforeach; ?> </tbody> </table> <?php endif; ?>
function shortcode_jw_twitter($atts, $content) { $jw_twitter_tweets = twitter_build($atts); if (is_array($jw_twitter_tweets)) { $output = '<div class="jw-twitter">'; $output .= '<ul class="jtwt">'; $fctr = '1'; foreach ($jw_twitter_tweets as $tweet) { $output .= '<li class="clearfix"><div class="category-icon-box"><i class="fa fa-twitter"></i></div><span>' . convert_links($tweet['text']) . '</span><br /><a class="twitter_time" target="_blank" href="http://twitter.com/' . $atts['username'] . '/statuses/' . $tweet['status_id'] . '">' . relative_time($tweet['created_at']) . '</a></li>'; if ($fctr == $atts['tweetstoshow']) { break; } $fctr++; } $output .= '</ul>'; //$output.='<div class="twitter-follow">' . (jw_option('jw_car_follow') ? jw_option('jw_car_follow') : __('Follow Us', 'designinvento')) . ' - <a target="_blank" href="http://twitter.com/' . $atts['username'] . '">@' . $atts['username'] . '</a></div>'; $output .= '</div>'; return $output; } else { return $jw_twitter_tweets; } }
$date = format_date($date, SHORTDATEFORMAT); $time = format_time($time, TIMEFORMAT); $count = $n + 1; $USERURL->insert(array('u' => $comment['user_id'])); ?> <a name="c<?php echo $count; ?> "></a><strong><?php echo _htmlentities($comment['firstname'] . ' ' . $comment['lastname']); ?> :</strong> <?php echo $commenttext; ?> <small>(<?php echo relative_time($comment['posted']); ?> )</small><br><a href="<?php echo $comment['url']; ?> ">Read annotation</a> | <a href="<?php echo $USERURL->generate(); ?> " title="See more information about this user">All by this user</a> </li> <?php } ?> </ul> <?php if ($this_page == 'home') { $MOREURL = new URL('comments_recent');
public function Current() { $row = $this->post_info->Current(); $this->count++; $row['count'] = $this->count; $row['created'] = relative_time($row['created']); if ($row['poster_id'] != 0) { $user = $this->dba->GetRow("SELECT * FROM " . USERS . " WHERE id = " . $row['poster_id']); if ($user['seen'] >= time() - Lib::GetSetting('sess.gc_maxlifetime')) { $row['online_status'] = $this->lang['L_ONLINE']; } else { $row['online_status'] = $this->lang['L_OFFLINE']; } $row['user_num_posts'] = $user['posts']; $row['user_rank'] = $user['rank'] != '' ? $user['rank'] : '--'; $row['avatar'] = $user['avatar'] != '' && $user['avatar'] != 0 ? '<img src="Uploads/Avatars/' . $user['id'] . '.gif" border="0" alt="" />' : ' '; $row['signature'] = $user['signature'] != '' && !is_null($user['signature']) && $row['allow_sigs'] == 1 ? '<br /><br />' . stripslashes($user['signature']) : ' '; } else { $row['poster_name'] = $this->lang['L_ADMINISTRATOR']; $row['online_status'] = '--'; $row['user_num_posts'] = '--'; $row['user_rank'] = '--'; } $row['name'] = stripslashes($row['name']); $row['name'] = $row['member_has_read'] == 0 ? '<span class="text-decoration:italic;">' . $row['name'] . '</span>' : $row['name']; $row['display'] = $this->pm['num_children'] == $this->count - 1 || $row['member_has_read'] == 0 ? 'block' : 'none'; $bbcode = new BBParser(stripslashes($row['body_text']), TRUE); //$row['quoted_text'] = str_replace("\r\n", '\n', addslashes($bbcode->Revert($row['body_text']))); $row['body_text'] = $bbcode->QuickExecute(); return $row; }
function get_theme_tweets($username, $consumerkey, $consumerkeysecret, $accesstoken, $accesstokensecret, $notweets) { //check settings and die if not set if (empty($username) || empty($consumerkey) || empty($consumerkeysecret) || empty($accesstoken) || empty($accesstokensecret)) { echo '<strong>Please fill all Twitter settings!</strong>'; return; } // yes, it needs update if (!(require_once 'twitter_oauth.php')) { echo '<strong>Couldn\'t find twitter_oauth.php!</strong>'; return; } if (!function_exists('getConnectionWithAccessToken')) { function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) { $connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret); return $connection; } } $connection = getConnectionWithAccessToken($consumerkey, $consumerkeysecret, $accesstoken, $accesstokensecret); $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $username . "&count=5") or die('Couldn\'t retrieve tweets! Wrong username?'); if (!empty($tweets->errors)) { if ($tweets->errors[0]->message == 'Invalid or expired token') { echo '<strong>' . $tweets->errors[0]->message . '!</strong><br />You will need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget; } else { echo '<strong>' . $tweets->errors[0]->message . '</strong>' . $after_widget; } return; } for ($i = 0; $i <= count($tweets); $i++) { if (!empty($tweets[$i])) { $tweets_array[$i]['created_at'] = $tweets[$i]->created_at; $tweets_array[$i]['text'] = $tweets[$i]->text; $tweets_array[$i]['status_id'] = $tweets[$i]->id_str; } } set_transient('twitter-bar-tweets', $tweets_array, 0); //convert links to clickable format function convert_links($status, $targetBlank = true, $linkMaxLen = 250) { // the target $target = $targetBlank ? " target=\"_blank\" " : ""; // convert link to url $status = preg_replace("/((http:\\/\\/|https:\\/\\/)[^ )\n]+)/e", "'<a href=\"\$1\" title=\"\$1\" {$target} >'. ((strlen('\$1')>={$linkMaxLen} ? substr('\$1',0,{$linkMaxLen}).'...':'\$1')).'</a>'", $status); // convert @ to follow $status = preg_replace("/(@([_a-z0-9\\-]+))/i", "<a href=\"http://twitter.com/\$2\" title=\"Follow \$2\" {$target} >\$1</a>", $status); // convert # to search $status = preg_replace("/(#([_a-z0-9\\-]+))/i", "<a href=\"https://twitter.com/search?q=\$2\" title=\"Search \$1\" {$target} >\$1</a>", $status); // return the status return $status; } //convert dates to readable format function relative_time($a) { //get current timestampt $b = strtotime("now"); //get timestamp when tweet created $c = strtotime($a); //get difference $d = $b - $c; //calculate different time values $minute = 60; $hour = $minute * 60; $day = $hour * 24; $week = $day * 7; if (is_numeric($d) && $d > 0) { //if less then 3 seconds if ($d < 3) { return "right now"; } //if less then minute if ($d < $minute) { return floor($d) . " seconds ago"; } //if less then 2 minutes if ($d < $minute * 2) { return "about 1 minute ago"; } //if less then hour if ($d < $hour) { return floor($d / $minute) . " minutes ago"; } //if less then 2 hours if ($d < $hour * 2) { return "about 1 hour ago"; } //if less then day if ($d < $day) { return floor($d / $hour) . " hours ago"; } //if more then day, but less then 2 days if ($d > $day && $d < $day * 2) { return "yesterday"; } //if less then year if ($d < $day * 365) { return floor($d / $day) . " days ago"; } //else return more than a year return "over a year ago"; } } //print tweets $tp_twitter_plugin_tweets = maybe_unserialize(get_transient('twitter-bar-tweets')); if (!empty($tp_twitter_plugin_tweets)) { $fctr = '1'; foreach ($tp_twitter_plugin_tweets as $tweet) { print '<li><span>' . convert_links($tweet['text']) . '</span><a class="created radius label blue" target="_blank" href="http://twitter.com/' . $username . '/statuses/' . $tweet['status_id'] . '">' . relative_time($tweet['created_at']) . '</a></li>'; if ($fctr == $notweets) { break; } $fctr++; } } }
</form> <div class="alert alert-success hidden" id="test_success"><strong>Success! We found a Location header in the response!</strong><br>Your post should be on your website now!<br><a href="" id="post_href">View your post</a></div> <div class="alert alert-danger hidden" id="test_error"><strong>Your endpoint did not return a Location header.</strong><br>See <a href="/creating-a-micropub-endpoint">Creating a Micropub Endpoint</a> for more information.</div> <div id="last_request_container" style="display: none;"> <h4>Request made to your Micropub endpoint</h4> <pre id="test_request" style="width: 100%; min-height: 140px;"></pre> </div> <?php if ($this->test_response) { ?> <h4>Last response from your Micropub endpoint <span id="last_response_date">(<?php echo relative_time($this->response_date); ?> )</span></h4> <?php } ?> <pre id="test_response" style="width: 100%; min-height: 240px;"><?php echo htmlspecialchars($this->test_response); ?> </pre> <div class="callout"> <p>Clicking "Post" will post this note to your Micropub endpoint. Below is some information about the request that will be made.</p> <table class="table table-condensed">
<ul class="tweet_list"> <li class="tweet_first tweet_odd"> <div class="the-tweet"> <span class="tweet_text"><?php echo convert_links($tweet['text']); ?> </span> <span class="tweet_time"><a class="twitter_time" target="_blank" href="http://twitter.com/<?php echo $b_data['TW_USERNAME']; ?> /statuses/<?php echo $tweet['status_id']; ?> "><?php echo relative_time($tweet['created_at']); ?> </a></span> </div> </li> </ul> <?php } } ?> </div> </div> </div> </div> </div>
} if ($i++ & 1) { $style .= ' alt'; } echo "<tr class='{$style}' onClick='loader.load (\"exam_modules.php?action=detail&exam={$ex}\")'>"; for ($f = 0; $f < $nof; ++$f) { echo '<td>' . $row[$f]; } echo '<td>'; if ($row['EndTime']) { echo '<span class=finished>Đã kết thúc</span>'; } else { if ($row['StartTime']) { echo '<span class=running>Đang thi</span>'; } else { echo mb_ucfirst(relative_time(strtotime($row['Schedule']))); } } } echo '</table>'; echo '</div>'; mysql_free_result($result); } if (isset($update['detail'])) { echo '<div id=detail>'; $result = $db->query("select\n\t\t\t\t\tLastName,\n\t\t\t\t\tFirstName,\n\t\t\t\t\tDuration,\n\t\t\t\t\tSchedule,\n\t\t\t\t\tStartTime,\n\t\t\t\t\tEndTime,\n\t\t\t\t\tNoQ\n\t\t\t\tfrom (select * from oes_Exam where ID = {$exam}) as E\n\t\t\t\t\tjoin oes_Teacher on E.Teacher = oes_Teacher.ID"); $row = mysql_fetch_array($result); echo '<table class=web20>'; $c = 0; echo '<tr' . ($c++ & 1 ? ' class=odd' : null) . '><td>Giáo viên<td>' . $row['LastName'] . ' ' . $row['FirstName']; echo '<tr' . ($c++ & 1 ? ' class=odd' : null) . '><td>Thời gian<td>' . $row['Duration'] . ' phút';
function widget($args, $instance) { extract($args); if (!empty($instance['title'])) { $title = apply_filters('widget_title', $instance['title']); } echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } //check settings and die if not set if (empty($instance['username'])) { echo '<strong>Please fill all widget settings!</strong>' . $after_widget; return; } if (function_exists('ot_get_option')) { $consumerkey = ''; if (ot_get_option('meganews_twitter_consumer_key')) { $consumerkey = ot_get_option('meganews_twitter_consumer_key'); } $consumersecret = ''; if (ot_get_option('meganews_twitter_consumer_secret')) { $consumersecret = ot_get_option('meganews_twitter_consumer_secret'); } $accesstoken = ''; if (ot_get_option('meganews_twitter_access_token')) { $accesstoken = ot_get_option('meganews_twitter_access_token'); } $accesstokensecret = ''; if (ot_get_option('meganews_twitter_access_secret_token')) { $accesstokensecret = ot_get_option('meganews_twitter_access_secret_token'); } $connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret); $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $instance['username'] . "&count=10") or die('Couldn\'t retrieve tweets! Wrong username?'); } if (!empty($tweets->errors)) { if ($tweets->errors[0]->message == 'Invalid or expired token') { echo '<strong>' . $tweets->errors[0]->message . '!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget; } else { echo '<strong>' . $tweets->errors[0]->message . '</strong>' . $after_widget; } return; } for ($i = 0; $i <= count($tweets); $i++) { if (!empty($tweets[$i])) { $tweets_array[$i]['created_at'] = $tweets[$i]->created_at; $tweets_array[$i]['text'] = $tweets[$i]->text; $tweets_array[$i]['status_id'] = $tweets[$i]->id_str; } } //save tweets to wp option update_option('tp_twitter_plugin_tweets', serialize($tweets_array)); update_option('tp_twitter_plugin_last_cache_time', time()); echo '<!-- twitter cache has been updated! -->'; $tp_twitter_plugin_tweets = maybe_unserialize(get_option('tp_twitter_plugin_tweets')); if (!empty($tp_twitter_plugin_tweets)) { print ' <div class="twitter_updates"> <ul class="tweet_list">'; $fctr = '1'; foreach ($tp_twitter_plugin_tweets as $tweet) { print '<li>' . convert_links($tweet['text']) . '<br /><span class="tweet_time"><a target="_blank" href="http://twitter.com/' . $instance['username'] . '/statuses/' . $tweet['status_id'] . '">' . relative_time($tweet['created_at']) . '</a></span></li>'; if ($fctr == $instance['tweetstoshow']) { break; } $fctr++; } print ' </ul> </div>'; } echo $after_widget; }
</tr> </thead> <tbody> <?php foreach ($commits as $commit) { ?> <?php if ($commit->id > $this->settings_lib->item('updates.last_commit')) { ?> <tr> <td><?php echo anchor('http://github.com/' . $commit->author->name, $commit->author->name, array('target' => '_blank')); ?> </td> <td><?php echo relative_time(strtotime($commit->committed_date)); ?> </td> <td><?php echo $commit->message; ?> </td> </tr> <?php } ?> <?php } ?> </tbody> </table>
/** * Gets the markup for notifications and returns the string that should be displayed * * @param integar $author_id The user ID of the person who sent the notification * @param string $author_name The username of the person who sent the notification * @param integar $type The type of notification being retrieved * @param integar $message_time The unix time of when the message was sent * @param string $misc1 A miscellaneous string that can be used for anything * @param string $misc2 A miscellaneous string that can be used for anything * @param string $misc3 A miscellaneous string that can be used for anything * @return string The notification the way it should be displayed */ function get_markup($author_id, $author_name, $type, $message_time, $misc1, $misc2, $misc3) { global $db; $markup = ""; $longago = relative_time($message_time); $result = $db->execute("\n\t\t\tSELECT markup \n\t\t\tFROM arrowchat_notifications_markup \n\t\t\tWHERE type='" . $type . "'\n\t\t"); if ($result and $db->count_select() > 0) { $row = $db->fetch_array($result); $markup = $row['markup']; $markup = str_replace("{author_name}", $author_name, $markup); $markup = str_replace("{author_id}", $author_id, $markup); $markup = str_replace("{longago}", $longago, $markup); $markup = str_replace("{message_time}", $message_time, $markup); $markup = str_replace("{misc1}", $misc1, $markup); $markup = str_replace("{misc2}", $misc2, $markup); $markup = str_replace("{misc3}", $misc3, $markup); } return $markup; }
$report_info[] = array('id' => $id, 'from' => $report_from, 'from_name' => $from_name, 'about' => $report_about, 'about_name' => $about_name, 'previous_warnings' => $previous_warnings, 'time' => relative_time($report_time), 'unix' => $report_time); } else { // Report is already completed or being worked on, send error $error[] = array('t' => '1', 'm' => $language[182]); $response['error'] = $error; header('Content-type: application/json; charset=utf-8'); echo json_encode($response); close_session(); exit; } // Mark this user as working on the ticket $db->execute("\n\t\t\tUPDATE arrowchat_reports\n\t\t\tSET working_time = " . time() . ",\n\t\t\t\tworking_by = '" . $db->escape_string($userid) . "'\n\t\t\tWHERE report_about = '" . $db->escape_string($report_about) . "'\n\t\t\t\tAND completed_time = 0\n\t\t"); // Return the list of reports about the user $result = $db->execute("\n\t\t\tSELECT id, report_time\n\t\t\tFROM arrowchat_reports\n\t\t\tWHERE report_about = '" . $db->escape_string($report_about) . "'\n\t\t\t\tAND completed_time = 0\n\t\t\tORDER BY report_time ASC\n\t\t"); while ($row = $db->fetch_array($result)) { $reports[] = array('id' => $row['id'], 'time' => relative_time($row['report_time'])); } if (!empty($report_chatroom)) { // Get the last ID before the report $last_id = 0; $result = $db->execute("\n\t\t\t\tSELECT id\n\t\t\t\tFROM arrowchat_chatroom_messages\n\t\t\t\tWHERE (chatroom_id = '" . $db->escape_string($report_chatroom) . "'\n\t\t\t\t\tAND sent <= " . $report_time . "\n\t\t\t\t\tAND action = 0)\n\t\t\t\tORDER BY sent DESC\n\t\t\t\tLIMIT 1\n\t\t\t"); if ($row = $db->fetch_array($result)) { $last_id = $row['id']; } // Get Chat room history around report time +/- 50 messages $result = $db->execute("\n\t\t\t\tSELECT id, username, message, sent, user_id, global_message, is_mod, is_admin\n\t\t\t\tFROM arrowchat_chatroom_messages\n\t\t\t\tWHERE (chatroom_id = '" . $db->escape_string($report_chatroom) . "'\n\t\t\t\t\tAND id <= " . $last_id . "\n\t\t\t\t\tAND action = 0)\n\t\t\t\tORDER BY sent DESC\n\t\t\t\tLIMIT 50\n\t\t\t"); while ($chatroom_history = $db->fetch_array($result)) { $temp_array[] = $chatroom_history; } $temp_array = array_reverse($temp_array); $result = $db->execute("\n\t\t\t\tSELECT id, username, message, sent, user_id, global_message, is_mod, is_admin\n\t\t\t\tFROM arrowchat_chatroom_messages\n\t\t\t\tWHERE (chatroom_id = '" . $db->escape_string($report_chatroom) . "'\n\t\t\t\t\tAND id > " . $last_id . "\n\t\t\t\t\tAND action = 0)\n\t\t\t\tORDER BY sent ASC\n\t\t\t\tLIMIT 50\n\t\t\t");
return $prefix . $diff . ' month' . ($diff != 1 ? 's' : '') . $postfix; } return date($fallback, strtotime($date)); } if ($tweets) { ?> <div id="twitter" class="widget"> <ul class="tweets nolist"> <h6><?php esc_html_e("Live from Twitter", "twentysixteen"); ?> </h6> <?php foreach ($tweets as $tweet) { ?> <li> <span class="tweet-date"><?php echo esc_html(relative_time($tweet->created_at)); ?> </span> <?php print links($tweet->text); ?> </li> <?php } ?> </ul> </div> <?php }
$referral = fetch_one($referral_query); } $ua = $mysqli->real_escape_string($_SERVER['HTTP_USER_AGENT']); $ip = getIP(); $date = date("Y-m-d H:i:s"); $sql = "INSERT INTO dispenses(amount, dispensed, email, ip, useragent) "; $sql .= "VALUES('{$amount}', '{$date}', '{$address}', '{$ip}', '{$ua}')"; sql_query($sql); if ($referral != 0) { $referredamount = $amount * ($referPercent / 100); $sql = "UPDATE balances SET balance = balance + {$referredamount}, totalbalance = totalbalance + {$referredamount} "; $sql .= "WHERE id='{$referral}'"; sql_query($sql); } $app->view()->setData('canClaim', true); $app->view()->setData('nextClaim', relative_time(time() + 1)); $app->flash('amount', $amount); } else { $app->flash('error', "CAPTCHA incorrect. Please try again."); } $app->redirect($app->urlFor('faucet')); })->name('claim'); $app->post("/cashout", $checkaddress($app, true), function () use($app) { global $cashout; $address = $app->view()->getData('address'); $balance_query = sql_query("SELECT balance FROM balances WHERE email='{$address}'"); if ($balance_query->num_rows) { $balance = fetch_one($balance_query); if ($balance >= $cashout) { sql_query("UPDATE balances SET balance = balance - {$balance} WHERE email='{$address}'"); // race attacks check
?> <div class="footer-twitter-wrapper boxed-style"> <div class="container twitter-container"> <i class="gdl-twitter-icon icon-twitter"></i> <div class="gdl-twitter-wrapper"> <div class="gdl-twitter-navigation"> <a class="prev icon-angle-left"></a> <a class="next icon-angle-right"></a> </div> <ul id="gdl-twitter" > <?php foreach ($tweets_data as $each_tweet) { echo '<li>'; echo '<span>' . convert_links($each_tweet['text']) . '</span>'; echo '<a class="date" target="_blank" href="http://twitter.com/' . $twitter_id . '/statuses/' . $each_tweet['status_id'] . '">' . relative_time($each_tweet['created_at']) . '</a>'; echo '</li>'; } ?> </ul> <script type="text/javascript"> jQuery(document).ready(function(){ var twitter_wrapper = jQuery('ul#gdl-twitter'); twitter_wrapper.each(function(){ var fetch_num = jQuery(this).children().length; var twitter_nav = jQuery(this).siblings('div.gdl-twitter-navigation'); if( fetch_num > 0 ){ gdl_cycle_resize(twitter_wrapper);
} } function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) { $connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret); return $connection; } $connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret); $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $username . "&count=" . $count) or die('Couldn\'t retrieve tweets! Wrong username?'); if (!empty($tweets->errors)) { if ($tweets->errors[0]->message == 'Invalid or expired token') { echo '<strong>' . $tweets->errors[0]->message . '!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget; } else { echo '<strong>' . $tweets->errors[0]->message . '</strong>' . $after_widget; } return; } for ($i = 0; $i <= count($tweets); $i++) { if (!empty($tweets[$i])) { $tweets_array[$i]['created_at'] = $tweets[$i]->created_at; $tweets_array[$i]['text'] = $tweets[$i]->text; $tweets_array[$i]['status_id'] = $tweets[$i]->id_str; } } foreach ($tweets_array as $tweet) { $timeline .= '<li>'; $timeline .= '<span class="tweet_text">' . convert_links($tweet['text']) . '</span> '; $timeline .= '<a class="twitter_time" target="_blank" href="http://twitter.com/' . $username . '/statuses/' . $tweet['status_id'] . '">' . relative_time($tweet['created_at']) . '</a>'; $timeline .= '</li>'; } echo $timeline;
<?php $i = 0; while (comments()) { $i++; ?> <li class="comment" id="comment-<?php echo comment_id(); ?> "> <div class="wrap"> <h2><?php echo comment_name(); ?> </h2> <time><?php echo relative_time(comment_time()); ?> </time> <div class="content"> <?php echo comment_text(); ?> </div> <span class="counter"><?php echo $i; ?> </span> </div> </li>
/** * Function: view * Views a post. */ public function view($attrs = null, $args = array()) { if (isset($attrs)) { $post = Post::from_url($attrs, array("drafts" => true)); } else { $post = new Post(array("url" => @$_GET['url']), array("drafts" => true)); } if ($post->no_results) { return false; } if (oneof(@$attrs["url"], @$attrs["clean"]) == "feed" and (count(explode("/", trim($post_url, "/"))) > count($args) or end($args) != "feed")) { $this->feed = false; } if (!$post->theme_exists()) { error(__("Error"), __("The feather theme file for this post does not exist. The post cannot be displayed.")); } if ($post->status == "draft") { Flash::message(__("This post is a draft.")); } if ($post->status == "scheduled") { Flash::message(_f("This post is scheduled to be published " . relative_time($post->created_at))); } if ($post->groups() and !substr_count($post->status, "{" . Visitor::current()->group->id . "}")) { Flash::message(_f("This post is only visible by the following groups: %s.", $post->groups())); } $this->display(array("pages/view", "pages/index"), array("post" => $post, "posts" => array($post)), $post->title()); }
?> " title="<?php echo article_title(); ?> "><?php echo article_title(); ?> </a> </h2> <footer> Posted <time datetime="<?php echo date(DATE_W3C, article_time()); ?> "><?php echo relative_time(article_time()); ?> </time> by <?php echo article_author('real_name'); ?> . </footer> </article> <hr> </li> <?php } ?> </ul> <?php
public function widget($args, $instance) { extract($args); echo $before_widget; if (isset($instance['title'])) { $title = $instance['title']; } else { $title = false; } if ($title) { echo $before_title; echo $title; echo $after_title; } //check settings and die if not set if (empty($instance['consumerkey']) || empty($instance['consumersecret']) || empty($instance['accesstoken']) || empty($instance['accesstokensecret']) || empty($instance['cachetime']) || empty($instance['username'])) { echo '<strong>Please fill all widget settings!</strong>' . $after_widget; return; } //convert links to clickable format if (!function_exists('convert_links')) { function convert_links($status, $targetBlank = true, $linkMaxLen = 250) { // the target $target = $targetBlank ? " target=\"_blank\" " : ""; // convert link to url $status = preg_replace("/((http:\\/\\/|https:\\/\\/)[^ )\r\n]+)/e", "'<a href=\"\$1\" title=\"\$1\" {$target} >'. ((strlen('\$1')>={$linkMaxLen} ? substr('\$1',0,{$linkMaxLen}).'...':'\$1')).'</a>'", $status); // convert @ to follow $status = preg_replace("/(@([_a-z0-9\\-]+))/i", "<a href=\"http://twitter.com/\$2\" title=\"Follow \$2\" {$target} >\$1</a>", $status); // convert # to search $status = preg_replace("/(#([_a-z0-9\\-]+))/i", "<a href=\"https://twitter.com/search?q=\$2\" title=\"Search \$1\" {$target} >\$1</a>", $status); // return the status return $status; } } if (!function_exists('relative_time')) { //convert dates to readable format function relative_time($a) { //get current timestampt $b = time(); //get timestamp when tweet created if (is_integer($a)) { $c = $a; } else { $c = strtotime($a); } //get difference $d = $b - $c; //calculate different time values $minute = 60; $hour = $minute * 60; $day = $hour * 24; $week = $day * 7; if (is_numeric($d) && $d > 0) { //if less then 3 seconds if ($d < 3) { return "right now"; } //if less then minute if ($d < $minute) { return floor($d) . " seconds ago"; } //if less then 2 minutes if ($d < $minute * 2) { return "about 1 minute ago"; } //if less then hour if ($d < $hour) { return floor($d / $minute) . " minutes ago"; } //if less then 2 hours if ($d < $hour * 2) { return "about 1 hour ago"; } //if less then day if ($d < $day) { return floor($d / $hour) . " hours ago"; } //if more then day, but less then 2 days if ($d > $day && $d < $day * 2) { return "yesterday"; } //if less then year if ($d < $day * 365) { return floor($d / $day) . " days ago"; } //else return more than a year return "over a year ago"; } } } // $tp_twitter_plugin_tweets = maybe_unserialize(get_option('tp_twitter_plugin_tweets')); require_once locate_template('/inc/lib/twitteroauth.php'); $twitter = new DFDTwitter(); $tp_twitter_plugin_tweets = $twitter->getTweets(); if (!empty($tp_twitter_plugin_tweets)) { $image = $tp_twitter_plugin_tweets[0]['image']; $screen_name = $tp_twitter_plugin_tweets[0]['name']; echo '<div class="tweets-author"> <img src="' . $image . '" alt="" /> <strong>' . $screen_name . ' <span>@' . $instance['username'] . '</span></strong> '; ?> <a href="https://twitter.com/<?php echo $instance['username']; ?> " class="twitter-follow-button" data-show-count="false" data-lang="en"><?php _e('Follow me', 'dfd'); ?> </a> <script>!function (d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (!d.getElementById(id)) { js = d.createElement(s); js.id = id; js.src = "//platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs); } }(document, "script", "twitter-wjs");</script> <?php echo '</div>'; print '<div class="tweet-list">'; $fctr = '1'; foreach ($tp_twitter_plugin_tweets as $tweet) { print '<div class="tweet"><i class="soc_icon-twitter-3"></i>' . $tweet['text'] . '<div class="time">' . relative_time($tweet['time']) . '</div></div>'; if ($fctr == $instance['tweetstoshow']) { break; } $fctr++; } if ($instance['read_all'] == 1) { print DFD_HTML::read_more('https://twitter.com/' . $instance['username'], __('Read all tweets', 'dfd')); } print '</div>'; } echo $after_widget; }