本文整理汇总了PHP中Track::is_recently_played方法的典型用法代码示例。如果您正苦于以下问题:PHP Track::is_recently_played方法的具体用法?PHP Track::is_recently_played怎么用?PHP Track::is_recently_played使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Track
的用法示例。
在下文中一共展示了Track::is_recently_played方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: web_post_vote
/**
* (Web service method) Submit vote for current track
* @param mixed[] $args time_utc (YYYY-MM-DD); stream_title; value (-5 .. 5); nick; user_id; is_authed (0|1)
* @return mixed[] status; error_message; output (what to announce in IRC chat room)
*/
private function web_post_vote($args)
{
$time_utc = $args['time_utc'];
// YYYY-MM-DD HH:MM:SS
$stream_title = $args['stream_title'];
$nick = $args['nick'];
$user_id = $args['user_id'];
$is_authed = $args['is_authed'];
$value_parts = explode(' ', $args['value'], 2);
$value = str_replace(['[', ']', '{', '}', '"', '\''], '', $value_parts[0]);
if (count($value_parts) == 1) {
$comment = '';
} else {
$comment = $value_parts[1];
}
$opt = Options::get_instance();
if (is_numeric($value)) {
$num = (int) $value;
if ($num < -5 || $num > 5) {
$num = FALSE;
}
} else {
$num = FALSE;
}
if ($num === FALSE) {
$this->fail($nick . ': Invalid vote value. Say "' . explode(' ', $opt->cmd_help)[0] . '" for help.');
}
$track_id = Track::create_or_get_id($stream_title);
if (!Track::is_recently_played($track_id)) {
$this->fail($nick . ': "' . $stream_title . '" wasn\'t played recently!');
}
$vote_id = Vote::get_recent_id($track_id, $nick);
if ($vote_id) {
Vote::delete($vote_id);
$txt_vote_response = $opt->txt_revote_response;
$priv = $opt->txt_revote_response_switch;
} else {
$txt_vote_response = $opt->txt_vote_response;
$priv = $opt->txt_vote_response_switch;
}
Vote::new_vote($time_utc, $track_id, $stream_title, $num, $nick, $user_id, $is_authed, $comment);
if ($num > 0) {
$num_txt = '+' . $num;
} else {
$num_txt = (string) $num;
}
$out = str_ireplace('${stream_title}', $args['stream_title'], $txt_vote_response);
$out = str_ireplace('${nick}', $nick, $out);
$out = str_ireplace('${value}', $num_txt, $out);
Track::update_vote($track_id);
return array('status' => 'ok', 'error_message' => '', 'output' => $out, 'private' => $priv);
}