当前位置: 首页>>代码示例>>PHP>>正文


PHP relative_time函数代码示例

本文整理汇总了PHP中relative_time函数的典型用法代码示例。如果您正苦于以下问题:PHP relative_time函数的具体用法?PHP relative_time怎么用?PHP relative_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了relative_time函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: widget

 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;
 }
开发者ID:shimion,项目名称:preview1,代码行数:57,代码来源:twitter-widget.php

示例2: Execute

 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;
 }
开发者ID:BackupTheBerlios,项目名称:k4bb,代码行数:46,代码来源:member.php

示例3: widget

 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
//.........这里部分代码省略.........
开发者ID:sumovska,项目名称:jodi,代码行数:101,代码来源:widget-twitter.php

示例4: get_guest_details

        }
        $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');
开发者ID:Lovinity,项目名称:EQM,代码行数:31,代码来源:receive_moderation.php

示例5: strlen

</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) ? "&mdash;" : '<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 
开发者ID:jotavejv,项目名称:CMS,代码行数:31,代码来源:repeatables_list.php

示例6: _e

?>
</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:");
开发者ID:JocelynDelalande,项目名称:Lilina,代码行数:31,代码来源:index.php

示例7: date

            ?>
</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 
开发者ID:Ereza,项目名称:Fansubs.cat,代码行数:31,代码来源:index.php

示例8: date

          <?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() ? "&mdash;" : '<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');
开发者ID:JordietYahii,项目名称:CMS,代码行数:31,代码来源:pages_edit.php

示例9: widget

 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
//.........这里部分代码省略.........
开发者ID:hiroki-tkg,项目名称:bitmaker,代码行数:101,代码来源:tweets.php

示例10: foreach

<?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 
开发者ID:brkrishna,项目名称:freelance,代码行数:31,代码来源:activity_list.php

示例11: isset

<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; ?>
开发者ID:ndcisiv,项目名称:Bonfire,代码行数:29,代码来源:index.php

示例12: shortcode_jw_twitter

 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;
     }
 }
开发者ID:Bitcoinsulting,项目名称:website-ads,代码行数:22,代码来源:twitter-function.php

示例13: format_date

        $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');
开发者ID:udp12,项目名称:theyworkforyou,代码行数:31,代码来源:comments_recent.php

示例14: Current

 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;
 }
开发者ID:BackupTheBerlios,项目名称:k4bb,代码行数:31,代码来源:privmsgs.class.php

示例15: get_theme_tweets

 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";
//.........这里部分代码省略.........
开发者ID:primarydesign,项目名称:the-color-mint,代码行数:101,代码来源:twitter_gettweets.php


注:本文中的relative_time函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。