• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP nice_time函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: nice_time

    $score2 = $match['team2']['score'];
    $series = "{$score1}:{$score2}";
    $timeStamp = $match['starttime_unix'];
    if ($score1 == $score2) {
        $winner = "x";
    } else {
        if ($score1 > $score2) {
            $team1 = '<b>' . $team1 . '</b>';
            $winner = ">";
        } else {
            $team2 = '<b>' . $team2 . '</b>';
            $winner = "<";
        }
    }
    if ($match['status'] == 2) {
        $date = nice_time($match['timediff']);
        $gameArray["eventDone"][] = "<tr class='d2mtrow eventDone' href='{$linkID}' title='{$eventName}' rel='tooltip'><td alt='{$timeStamp}' class='push-tt gg_date series'>{$series}</td><td><img class='dd2-teamimg' src='{$img1}' width='28px' height='18px'> {$team1}</td><td class='winResult' data-winner='{$winner}'>{$winner}</td><td><img class='dd2-teamimg' src='{$img2}' width='28px' height='18px'> {$team2}</td></tr>";
    }
    if ($i == 13) {
        break;
    }
    $i++;
}
$gameArray["eventDone"] = array_reverse($gameArray["eventDone"]);
$str = trim(json_encode($gameArray));
$filestr = "api.json";
$fp = @fopen($filestr, 'w');
fwrite($fp, $str);
fwrite($fp, "");
fclose($fp);
echo $str;
开发者ID:jcmackie,项目名称:d2mt,代码行数:31,代码来源:index.php


示例2: ON

 $query = $db->simple_select('banned b LEFT JOIN ' . TABLE_PREFIX . 'users a ON (b.admin=a.uid)', 'b.*, a.username AS adminuser', "b.uid='{$uid}'", array('limit' => 1));
 $memban = $db->fetch_array($query);
 if ($memban['reason']) {
     $memban['reason'] = htmlspecialchars_uni($parser->parse_badwords($memban['reason']));
 } else {
     $memban['reason'] = $lang->na;
 }
 if ($memban['lifted'] == 'perm' || $memban['lifted'] == '' || $memban['bantime'] == 'perm' || $memban['bantime'] == '---') {
     $banlength = $lang->permanent;
     $timeremaining = $lang->na;
 } else {
     // Set up the array of ban times.
     $bantimes = fetch_ban_times();
     $banlength = $bantimes[$memban['bantime']];
     $remaining = $memban['lifted'] - TIME_NOW;
     $timeremaining = nice_time($remaining, array('short' => 1, 'seconds' => false)) . "";
     if ($remaining < 3600) {
         $timeremaining = "<span style=\"color: red;\">({$timeremaining} {$lang->ban_remaining})</span>";
     } else {
         if ($remaining < 86400) {
             $timeremaining = "<span style=\"color: maroon;\">({$timeremaining} {$lang->ban_remaining})</span>";
         } else {
             if ($remaining < 604800) {
                 $timeremaining = "<span style=\"color: green;\">({$timeremaining} {$lang->ban_remaining})</span>";
             } else {
                 $timeremaining = "({$timeremaining} {$lang->ban_remaining})";
             }
         }
     }
 }
 $memban['adminuser'] = build_profile_link($memban['adminuser'], $memban['admin']);
开发者ID:nicopinto,项目名称:fantasitura.com,代码行数:31,代码来源:member.php


示例3: _remap

 public function _remap()
 {
     if ($this->config->item('auth_two_factor_enable')) {
         $_return_to = $this->input->get('return_to', TRUE);
         $_remember = $this->input->get('remember', TRUE);
         $_user_id = $this->uri->segment(3);
         $_user = $this->user_model->get_by_id($_user_id);
         if (!$_user) {
             $this->session->set_flashdata('error', lang('auth_twofactor_token_unverified'));
             if ($_return_to) {
                 redirect('auth/login?return_to=' . $_return_to);
                 return;
             } else {
                 redirect('auth/login');
                 return;
             }
         }
         $_salt = $this->uri->segment(4);
         $_token = $this->uri->segment(5);
         $_ip = $this->input->ip_address();
         $_login_method = $this->uri->segment(6) ? $this->uri->segment(6) : 'native';
         //	Safety first
         switch ($_login_method) {
             case 'facebook':
             case 'twitter':
             case 'linkedin':
             case 'native':
                 //	All good, homies.
                 break;
             default:
                 $_login_method = 'native';
                 break;
         }
         if ($this->auth_model->verify_two_factor_token($_user->id, $_salt, $_token, $_ip)) {
             //	Token is valid, generate a new one for the next request
             $this->data['token'] = $this->auth_model->generate_two_factor_token($_user->id);
             //	Set data for the views
             $this->data['user_id'] = $_user->id;
             $this->data['login_method'] = $_login_method;
             $this->data['return_to'] = $_return_to;
             $this->data['remember'] = $_remember;
             if ($this->input->post('answer')) {
                 //	Validate the answer, if correct then log user in and forward, if not
                 //	then generate a new token and show errors
                 $this->data['question'] = $this->user_model->get_security_question($_user->id);
                 $_valid = $this->user_model->validate_security_answer($this->data['question']->id, $_user->id, $this->input->post('answer'));
                 if ($_valid) {
                     //	Set login data for this user
                     $this->user_model->set_login_data($_user->id);
                     //	If we're remembering this user set a cookie
                     if ($_remember) {
                         $this->user_model->set_remember_cookie($_user->id, $_user->password, $_user->email);
                     }
                     //	Update their last login and increment their login count
                     $this->user_model->update_last_login($_user->id);
                     // --------------------------------------------------------------------------
                     //	Generate an event for this log in
                     create_event('did_log_in', $_user->id, 0, NULL, array('method' => $_login_method));
                     // --------------------------------------------------------------------------
                     //	Say hello
                     if ($_user->last_login) {
                         $this->load->helper('date');
                         $_last_login = $this->config->item('auth_show_nicetime_on_login') ? nice_time(strtotime($_user->last_login)) : user_datetime($_user->last_login);
                         if ($this->config->item('auth_show_last_ip_on_login')) {
                             $this->session->set_flashdata('message', lang('auth_login_ok_welcome_with_ip', array($_user->first_name, $_last_login, $_user->last_ip)));
                         } else {
                             $this->session->set_flashdata('message', lang('auth_login_ok_welcome', array($_user->first_name, $_last_login)));
                         }
                     } else {
                         $this->session->set_flashdata('message', lang('auth_login_ok_welcome_notime', array($_user->first_name)));
                     }
                     // --------------------------------------------------------------------------
                     //	Delete the token we generated, its no needed, eh!
                     $this->auth_model->delete_two_factor_token($this->data['token']['id']);
                     // --------------------------------------------------------------------------
                     $_redirect = $_return_to != site_url() ? $_return_to : $_user->group_homepage;
                     redirect($_redirect);
                     return;
                 } else {
                     $this->data['error'] = lang('auth_twofactor_answer_incorrect');
                     //	Ask away cap'n!
                     $this->data['page']->title = lang('auth_twofactor_answer_title');
                     $this->load->view('structure/header', $this->data);
                     $this->load->view('auth/security_question/ask', $this->data);
                     $this->load->view('structure/footer', $this->data);
                 }
             } else {
                 //	Determine whether the user has any security questions set
                 $this->data['question'] = $this->user_model->get_security_question($_user->id);
                 if ($this->data['question']) {
                     //	Ask away cap'n!
                     $this->data['page']->title = 'Security Question';
                     $this->load->view('structure/header', $this->data);
                     $this->load->view('auth/security_question/ask', $this->data);
                     $this->load->view('structure/footer', $this->data);
                 } else {
                     //	Auth config stuffz
                     $this->data['questions'] = $this->config->item('auth_two_factor_questions');
                     $this->data['num_questions'] = count($this->data['questions']) < $this->config->item('auth_two_factor_num_questions') ? count($this->data['questions']) : $this->config->item('auth_two_factor_num_questions');
                     $this->data['num_custom_questions'] = $this->config->item('auth_two_factor_num_custom_question');
//.........这里部分代码省略.........
开发者ID:nailsapp,项目名称:module-auth,代码行数:101,代码来源:security_questions.php


示例4: foreach

    </div>
  </div>

  <div class="tweets span-8 last">
    <h3>News from the road...</h3>
    <ul id="twitter">
      <?php 
foreach ($tweets as $tweet) {
    ?>
        <li>
          <span class="tweet"><?php 
    echo $tweet->getRawValue()->getHTMLHashtagsStripped();
    ?>
</span>
          <span class="time"><?php 
    echo nice_time($tweet->getDateTimeObject('created_at')->format('U'));
    ?>
</span>
          <div class="clear"></div>
        </li>
      <?php 
}
?>
    </ul>
    <h3>Post a comment...</h3>
    <fb:comments xid="followben" numposts="20" width="310" url="http://followben.co.uk/" css="http://followben.co.uk/css/fbcomments.css?1=2"></fb:comments>
  </div>

  <div class="clear"></div>

  <hr/>
开发者ID:benlumley,项目名称:followben,代码行数:31,代码来源:indexSuccess.php


示例5: while

		INNER JOIN status_channel ON status.id = status_channel.status_id 
		WHERE (status_channel.channel_id = ? ' . $chanzero . ') AND id < ?
		ORDER BY status_channel.status_id DESC LIMIT ?');
    $stmt->bind_param('idi', $_GET['cid'], $_GET['maxid'], $limit);
} else {
    $stmt = $mysqli->prepare('SELECT id, screen_name, profile_image_url, created_at, source, text 
		FROM status 
		INNER JOIN status_channel ON status.id = status_channel.status_id 
		WHERE status_channel.channel_id = ? ' . $chanzero . '
		ORDER BY status_channel.status_id DESC LIMIT ?');
    $stmt->bind_param('ii', $_GET['cid'], $limit);
}
$stmt->execute();
$stmt->bind_result($id, $screen_name, $profile_image_url, $created_at, $source, $text);
$next_page_maxid = NULL;
while ($stmt->fetch()) {
    $created_at_timestamp = strtotime($created_at);
    $tweets[] = array('id' => $id, 'screen_name' => $screen_name, 'profile_image_url' => $profile_image_url, 'created_at' => nice_time($created_at_timestamp), 'created_at_long' => date('m-d-y h:i A', $created_at_timestamp), 'source' => $source, 'text' => $text);
    $next_page_maxid = $id;
}
$stmt->close();
$return_array = array('tweets' => $tweets, 'next_page_maxid' => $next_page_maxid);
print to_json($return_array);
if ($do_cache) {
    $contents = ob_get_contents();
    ob_end_clean();
    $handle = fopen($cachefile, 'w');
    fwrite($handle, $contents);
    fclose($handle);
    include $cachefile;
}
开发者ID:nickcooley,项目名称:ISO-connect,代码行数:31,代码来源:cache_tweets.php


示例6: array

     }
 }
 $modpost_div = '<div id="modpost">' . $existing_info . '' . $lang->moderate_for . ' ' . $form->generate_numeric_field("modpost_time", $mybb->input['modpost_time'], array('style' => 'width: 3em;', 'min' => 0)) . ' ' . $modpost_options . '</div>';
 $lang->moderate_posts_info = $lang->sprintf($lang->moderate_posts_info, $user['username']);
 $form_container->output_row($form->generate_check_box("moderateposting", 1, $lang->moderate_posts, array("id" => "moderateposting", "onclick" => "toggleBox('modpost');", "checked" => $mybb->input['moderateposting'])), $lang->moderate_posts_info, $modpost_div);
 // Suspend posts
 // Generate check box
 $suspost_options = $form->generate_select_box('suspost_period', $periods, $mybb->input['suspost_period'], array('id' => 'suspost_period'));
 // Do we have any existing suspensions here?
 if ($user['suspendposting'] || $mybb->input['suspendposting'] && !empty($errors)) {
     $mybb->input['suspendposting'] = 1;
     if ($user['suspensiontime'] == 0 || $mybb->input['suspost_period'] == "never") {
         $existing_info = $lang->suspended_perm;
     } else {
         $remaining = $user['suspensiontime'] - TIME_NOW;
         $suspost_date = nice_time($remaining, array('seconds' => false));
         $color = 'inherit';
         if ($remaining < 3600) {
             $color = 'red';
         } elseif ($remaining < 86400) {
             $color = 'maroon';
         } elseif ($remaining < 604800) {
             $color = 'green';
         }
         $existing_info = $lang->sprintf($lang->suspend_length, $suspost_date, $color);
     }
 }
 $suspost_div = '<div id="suspost">' . $existing_info . '' . $lang->suspend_for . ' ' . $form->generate_numeric_field("suspost_time", $mybb->input['suspost_time'], array('style' => 'width: 3em;', 'min' => 0)) . ' ' . $suspost_options . '</div>';
 $lang->suspend_posts_info = $lang->sprintf($lang->suspend_posts_info, $user['username']);
 $form_container->output_row($form->generate_check_box("suspendposting", 1, $lang->suspend_posts, array("id" => "suspendposting", "onclick" => "toggleBox('suspost');", "checked" => $mybb->input['suspendposting'])), $lang->suspend_posts_info, $suspost_div);
 $form_container->end();
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:31,代码来源:users.php


示例7: _validate

 /**
  * Validate the supplied assets and if valid present the user with a reset form
  *
  * @access	public
  * @param	int		$id		The ID fo the user to reset
  * @param	strgin	hash	The hash to validate against
  * @return	void
  **/
 private function _validate($id, $hash)
 {
     //	Check auth credentials
     $_user = $this->user_model->get_by_id($id);
     // --------------------------------------------------------------------------
     if ($_user !== FALSE && isset($_user->salt) && $hash == md5($_user->salt)) {
         //	Valid combination
         if ($this->input->post()) {
             // Validate data
             $this->load->library('form_validation');
             // --------------------------------------------------------------------------
             //	Define rules
             $this->form_validation->set_rules('new_password', 'password', 'required|matches[confirm_pass]');
             $this->form_validation->set_rules('confirm_pass', 'confirmation', 'required');
             // --------------------------------------------------------------------------
             //	Set custom messages
             $this->form_validation->set_message('required', lang('fv_required'));
             $this->form_validation->set_message('matches', lang('fv_matches'));
             // --------------------------------------------------------------------------
             //	Run validation
             if ($this->form_validation->run()) {
                 //	Validated, update user and login.
                 $_data['forgotten_password_code'] = NULL;
                 $_data['temp_pw'] = NULL;
                 $_data['password'] = $this->input->post('new_password');
                 $_remember = (bool) $this->input->get('remember');
                 //	Reset the password
                 if ($this->user_model->update($id, $_data)) {
                     //	Log the user in
                     switch (APP_NATIVE_LOGIN_USING) {
                         case 'EMAIL':
                             $_login = $this->auth_model->login($_user->email, $this->input->post('new_password'), $_remember);
                             break;
                             // --------------------------------------------------------------------------
                         // --------------------------------------------------------------------------
                         case 'USERNAME':
                             $_login = $this->auth_model->login($_user->username, $this->input->post('new_password'), $_remember);
                             break;
                             // --------------------------------------------------------------------------
                         // --------------------------------------------------------------------------
                         case 'BOTH':
                         default:
                             $_login = $this->auth_model->login($_user->email, $this->input->post('new_password'), $_remember);
                             break;
                     }
                     if ($_login) {
                         if ($this->config->item('auth_two_factor_enable')) {
                             $_query = array();
                             if ($this->input->get('return_to')) {
                                 $_query['return_to'] = $this->input->get('return_to');
                             }
                             if ($_remember) {
                                 $_query['remember'] = $_remember;
                             }
                             $_query = $_query ? '?' . http_build_query($_query) : '';
                             //	Login was successful, redirect to the security questions page
                             redirect('auth/security_questions/' . $_login['user_id'] . '/' . $_login['two_factor_auth']['salt'] . '/' . $_login['two_factor_auth']['token'] . $_query);
                         } else {
                             //	Say hello
                             if ($_login['last_login']) {
                                 $this->load->helper('date');
                                 $_last_login = $this->config->item('auth_show_nicetime_on_login') ? nice_time(strtotime($_login['last_login'])) : user_datetime($_login['last_login']);
                                 if ($this->config->item('auth_show_last_ip_on_login')) {
                                     $this->session->set_flashdata('message', lang('auth_login_ok_welcome_with_ip', array($_login['first_name'], $_last_login, $_login['last_ip'])));
                                 } else {
                                     $this->session->set_flashdata('message', lang('auth_login_ok_welcome', array($_login['first_name'], $_last_login)));
                                 }
                             } else {
                                 $this->session->set_flashdata('message', lang('auth_login_ok_welcome_notime', array($_login['first_name'])));
                             }
                             //	Log user in and forward to wherever they need to go
                             if ($this->input->get('return_to')) {
                                 redirect($this->input->get('return_to'));
                                 return;
                             } elseif ($_user->group_homepage) {
                                 redirect($_user->group_homepage);
                                 return;
                             } else {
                                 redirect('/');
                                 return;
                             }
                         }
                     } else {
                         $this->data['error'] = lang('auth_forgot_reset_badlogin', site_url('auth/login'));
                     }
                 } else {
                     $this->data['error'] = lang('auth_forgot_reset_badupdate', $this->user_model->last_error());
                 }
             } else {
                 $this->data['error'] = lang('fv_there_were_errors');
             }
         }
//.........这里部分代码省略.........
开发者ID:nailsapp,项目名称:module-auth,代码行数:101,代码来源:reset_password.php


示例8: get_user_info_func


//.........这里部分代码省略.........
        }
        $tylrcvpd = $memprofile['tyl_unumrcvtyls'] / $daysreg;
        $tylrcvpd = round($tylrcvpd, 2);
        if ($tylrcvpd > $memprofile['tyl_unumrcvtyls']) {
            $tylrcvpd = $memprofile['tyl_unumrcvtyls'];
        }
        // Get total tyl and percentage
        $options = array("limit" => 1);
        $query = $db->simple_select($prefix . "stats", "*", "title='total'", $options);
        $total = $db->fetch_array($query);
        if ($total['value'] == 0) {
            $percent = "0";
            $percent_rcv = "0";
        } else {
            $percent = $memprofile['tyl_unumtyls'] * 100 / $total['value'];
            $percent = round($percent, 2);
            $percent_rcv = $memprofile['tyl_unumrcvtyls'] * 100 / $total['value'];
            $percent_rcv = round($percent_rcv, 2);
        }
        if ($percent > 100) {
            $percent = 100;
        }
        if ($percent_rcv > 100) {
            $percent_rcv = 100;
        }
        $memprofile['tyl_unumtyls'] = my_number_format($memprofile['tyl_unumtyls']);
        $memprofile['tyl_unumrcvtyls'] = my_number_format($memprofile['tyl_unumrcvtyls']);
        $tylpd_percent_total = $lang->sprintf($lang->tyl_tylpd_percent_total, my_number_format($tylpd), $tyl_thankslikes_given, $percent);
        $tylrcvpd_percent_total = $lang->sprintf($lang->tyl_tylpd_percent_total, my_number_format($tylrcvpd), $tyl_thankslikes_rcvd, $percent_rcv);
        addCustomField($lang->tyl_total_tyls_given, "{$memprofile['tyl_unumtyls']} ({$tylpd_percent_total})", $custom_fields_list);
        addCustomField($lang->tyl_total_tyls_rcvd, "{$memprofile['tyl_unumrcvtyls']} ({$tylrcvpd_percent_total})", $custom_fields_list);
    }
    if ($memprofile['timeonline'] > 0) {
        $timeonline = nice_time($memprofile['timeonline']);
        addCustomField($lang->timeonline, $timeonline, $custom_fields_list);
    }
    if ($mybb->settings['usereferrals'] == 1 && $memprofile['referrals'] > 0) {
        addCustomField($lang->members_referred, $memprofile['referrals'], $custom_fields_list);
    }
    if ($memperms['usereputationsystem'] == 1 && $displaygroup['usereputationsystem'] == 1 && $mybb->settings['enablereputation'] == 1 && ($mybb->settings['posrep'] || $mybb->settings['neurep'] || $mybb->settings['negrep'])) {
        addCustomField($lang->reputation, $memprofile['reputation'], $custom_fields_list);
    }
    if ($mybb->settings['enablewarningsystem'] != 0 && $memperms['canreceivewarnings'] != 0 && ($mybb->usergroup['canwarnusers'] != 0 || $mybb->user['uid'] == $memprofile['uid'] && $mybb->settings['canviewownwarning'] != 0)) {
        $warning_level = round($memprofile['warningpoints'] / $mybb->settings['maxwarningpoints'] * 100);
        if ($warning_level > 100) {
            $warning_level = 100;
        }
        addCustomField($lang->warning_level, $warning_level . '%', $custom_fields_list);
    }
    if ($memprofile['website']) {
        $memprofile['website'] = htmlspecialchars_uni($memprofile['website']);
        addCustomField($lang->homepage, $memprofile['website'], $custom_fields_list);
    }
    if ($memprofile['icq']) {
        addCustomField($lang->icq_number, $memprofile['icq'], $custom_fields_list);
    }
    if ($memprofile['aim']) {
        addCustomField($lang->aim_screenname, $memprofile['aim'], $custom_fields_list);
    }
    if ($memprofile['yahoo']) {
        addCustomField($lang->yahoo_id, $memprofile['yahoo'], $custom_fields_list);
    }
    if ($memprofile['msn']) {
        addCustomField($lang->msn, $memprofile['msn'], $custom_fields_list);
    }
    $query = $db->simple_select("userfields", "*", "ufid='{$uid}'");
开发者ID:dthiago,项目名称:tapatalk-mybb,代码行数:67,代码来源:get_user_info.php


示例9: htmlspecialchars_uni

                 $customfieldval = htmlspecialchars_uni($userfields[$field]);
             }
         }
     }
     $customfield['name'] = htmlspecialchars_uni($customfield['name']);
     eval("\$customfields .= \"" . $templates->get("member_profile_customfields_field") . "\";");
     $bgcolor = alt_trow();
 }
 if ($customfields) {
     eval("\$profilefields = \"" . $templates->get("member_profile_customfields") . "\";");
 }
 $memprofile['postnum'] = my_number_format($memprofile['postnum']);
 $lang->ppd_percent_total = $lang->sprintf($lang->ppd_percent_total, my_number_format($ppd), $percent);
 $formattedname = format_name($memprofile['username'], $memprofile['usergroup'], $memprofile['displaygroup']);
 if ($memprofile['timeonline'] > 0) {
     $timeonline = nice_time($memprofile['timeonline']);
 } else {
     $timeonline = $lang->none_registered;
 }
 $adminoptions = '';
 if ($mybb->usergroup['cancp'] == 1 && $mybb->config['hide_admin_links'] != 1) {
     eval("\$adminoptions = \"" . $templates->get("member_profile_adminoptions") . "\";");
 }
 $modoptions = '';
 if ($mybb->usergroup['canmodcp'] == 1) {
     $memprofile['usernotes'] = nl2br(htmlspecialchars_uni($memprofile['usernotes']));
     if (!empty($memprofile['usernotes'])) {
         if (strlen($memprofile['usernotes']) > 100) {
             $memprofile['usernotes'] = my_substr($memprofile['usernotes'], 0, 100) . '...';
         }
     } else {
开发者ID:GeorgeLVP,项目名称:mybb,代码行数:31,代码来源:member.php


示例10: _login_user

 /**
  * Update a user's access token and log them in to the app
  *
  * @access	public
  * @param	object $access_token The user's access token
  * @return	void
  **/
 protected function _login_user($access_token, $user)
 {
     //	Load the auth lang file
     $this->lang->load('auth', 'english');
     // --------------------------------------------------------------------------
     //	Check if the user is suspended.
     if ($user->is_suspended) {
         $this->session->set_flashdata('error', lang('auth_login_fail_suspended'));
         $this->_redirect($this->_return_to_fail);
         return;
     }
     // --------------------------------------------------------------------------
     //	Update token
     $_data['li_token'] = $access_token->access_token;
     $this->user_model->update($user->id, $_data);
     // --------------------------------------------------------------------------
     //	Two factor auth enabled?
     if ($this->config->item('auth_two_factor_enable')) {
         //	Generate a token
         $this->load->model('auth_model');
         $_token = $this->auth_model->generate_two_factor_token($user->id);
         if (!$_token) {
             show_fatal_error('Failed to generate two-factor auth token', 'A user tried to login with LinkedIn and the system failed to generate a two-factor auth token.');
         }
         $_query = array();
         $_query['return_to'] = $this->_return_to;
         $_query = array_filter($_query);
         if ($_query) {
             $_query = '?' . http_build_query($_query);
         } else {
             $_query = '';
         }
         redirect('auth/security_questions/' . $user->id . '/' . $_token['salt'] . '/' . $_token['token'] . '/linkedin' . $_query);
     } else {
         //	Set login details
         $this->user_model->set_login_data($user->id);
         // --------------------------------------------------------------------------
         //	Set welcome message
         if ($user->last_login) {
             $this->load->helper('date');
             $_last_login = $this->config->item('auth_show_nicetime_on_login') ? nice_time(strtotime($user->last_login)) : user_datetime($user->last_login);
             if ($this->config->item('auth_show_last_ip_on_login')) {
                 $this->session->set_flashdata('message', lang('auth_login_ok_welcome_with_ip', array($user->first_name, $_last_login, $user->last_ip)));
             } else {
                 $this->session->set_flashdata('message', lang('auth_login_ok_welcome', array($user->first_name, $_last_login)));
             }
         } else {
             $this->session->set_flashdata('message', lang('auth_login_ok_welcome_notime', array($user->first_name)));
         }
         // --------------------------------------------------------------------------
         //	Update the last login
         $this->user_model->update_last_login($user->id);
         // --------------------------------------------------------------------------
         //	Create an event for this event
         create_event('did_log_in', $user->id, 0, NULL, array('method' => 'linkedin'));
         // --------------------------------------------------------------------------
         //	Delete register token
         delete_cookie('liRegisterToken');
         // --------------------------------------------------------------------------
         //	If no return to value is defined, default to the group homepage
         if (!$this->_return_to) {
             $this->_return_to = $user->group_homepage;
         }
     }
     // --------------------------------------------------------------------------
     //	Redirect
     $this->_redirect($this->_return_to);
     return;
 }
开发者ID:nailsapp,项目名称:module-auth,代码行数:76,代码来源:li.php


示例11: login


//.........这里部分代码省略.........
             //	the next process will confirm the login and set this.
             if (!$this->config->item('auth_two_factor_enable')) {
                 //	Set login data for this user
                 $this->user_model->set_login_data($_user->id);
                 //	If we're remembering this user set a cookie
                 if ($remember) {
                     $this->user_model->set_remember_cookie($_user->id, $_user->password, $_user->email);
                 }
                 //	Update their last login and increment their login count
                 $this->user_model->update_last_login($_user->id);
             }
             // Return some helpful data
             $_return = array('user_id' => $_user->id, 'first_name' => $_user->first_name, 'last_login' => $_user->last_login, 'last_ip' => $_user->last_ip, 'homepage' => $_user->group_homepage, 'remember' => $remember);
             //	Two factor auth?
             if ($this->config->item('auth_two_factor_enable')) {
                 //	Generate token
                 $_return['two_factor_auth'] = $this->generate_two_factor_token($_user->id);
             }
             //	Temporary password?
             if ($_user->temp_pw) {
                 $_return['temp_pw'] = array();
                 $_return['temp_pw']['id'] = $_user->id;
                 $_return['temp_pw']['hash'] = md5($_user->salt);
             }
             return $_return;
             // --------------------------------------------------------------------------
             //	Is the password NULL? If so it means the account was created using an API of sorts
         } elseif ($_user->password === NULL) {
             switch (APP_NATIVE_LOGIN_USING) {
                 case 'EMAIL':
                     $_identifier = $_user->email;
                     break;
                     // --------------------------------------------------------------------------
                 // --------------------------------------------------------------------------
                 case 'USERNAME':
                     $_identifier = $_user->username;
                     break;
                     // --------------------------------------------------------------------------
                 // --------------------------------------------------------------------------
                 case 'BOTH':
                 default:
                     $_identifier = $_user->email;
                     break;
             }
             switch ($user->auth_method_id) {
                 //	Facebook Connect
                 case '2':
                     $this->_set_error('auth_login_fail_social_fb', site_url('auth/forgotten_password?identifier=' . $_identifier));
                     break;
                     //	Twitter
                 //	Twitter
                 case '3':
                     $this->_set_error('auth_login_fail_social_tw', site_url('auth/forgotten_password?identifier=' . $_identifier));
                     break;
                     //	LinkedIn
                 //	LinkedIn
                 case '5':
                     $this->_set_error('auth_login_fail_social_li', site_url('auth/forgotten_password?identifier=' . $_identifier));
                     break;
                     //	Other
                 //	Other
                 default:
                     $this->_set_error('auth_login_fail_social', site_url('auth/forgotten_password?identifier=' . $_identifier));
                     break;
             }
             return FALSE;
             // --------------------------------------------------------------------------
         } else {
             //	User was recognised but the password was wrong
             //	Increment the user's failed login count
             $this->user_model->increment_failed_login($_user->id, $this->brute_force_protection['expire']);
             //	Are we already blocked? Let them know...
             if ($_user->failed_login_count >= $this->brute_force_protection['limit']) {
                 //	Check if the block has expired
                 if (time() < strtotime($_user->failed_login_expires)) {
                     $_block_time = ceil($this->brute_force_protection['expire'] / 60);
                     $this->_set_error('auth_login_fail_blocked', $_block_time);
                     return FALSE;
                 }
                 //	Block has expired, reset the counter
                 $this->user_model->reset_failed_login($user->id);
             }
             //	Check if the password was changed recently
             if ($_user->password_changed) {
                 $_changed = strtotime($_user->password_changed);
                 $_recent = strtotime('-2 WEEKS');
                 if ($_changed > $_recent) {
                     $_changed_recently = nice_time($_changed);
                 }
             }
         }
     }
     //	Login failed
     if (empty($_changed_recently)) {
         $this->_set_error('auth_login_fail_general');
     } else {
         $this->_set_error('auth_login_fail_general_recent', $_changed_recently);
     }
     return FALSE;
 }
开发者ID:nailsapp,项目名称:module-auth,代码行数:101,代码来源:auth_model.php


示例12: login

 public function login()
 {
     $_email = $this->input->post('email');
     $_password = $this->input->post('password');
     $_remember = $this->input->post('remember');
     $_out = array();
     $_login = $this->auth_model->login($_email, $_password, $_remember);
     if ($_login) {
         /**
          * User was recognised and permitted to log in. Final check to
          * determine whether they are using a temporary password or not.
          *
          * $login will be an array containing the keys first_name, last_login, homepage;
          * the key temp_pw will be present if they are using a temporary password.
          *
          **/
         if (isset($_login['temp_pw'])) {
             /**
              * Temporary password detected, log user out and redirect to
              * temp password reset page.
              *
              * temp_pw will be an array containing the user's ID and hash
              *
              **/
             $_return_to = $this->data['return_to'] ? '?return_to=' . urlencode($this->data['return_to']) : NULL;
             $this->auth_model->logout();
             $_out['status'] = 401;
             $_out['error'] = 'Temporary Password';
             $_out['code'] = 2;
             $_out['goto'] = site_url('auth/reset_password/' . $_login['temp_pw']['id'] . '/' . $_login['temp_pw']['hash'] . $_return_to);
         } else {
             //	Finally! Send this user on their merry way...
             $_first_name = $_login['first_name'];
             if ($_login['last_login']) {
                 $this->load->helper('date');
                 $this->config->load('auth');
                 $_last_login = $this->config->item('auth_show_nicetime_on_login') ? nice_time(strtotime($_login['last_login'])) : user_datetime($_login['last_login']);
                 if ($this->config->item('auth_show_last_ip_on_login')) {
                     $_last_ip = $_login['last_ip'];
                     $this->session->set_flashdata('message', lang('auth_login_ok_welcome_with_ip', array($_first_name, $_last_login, $_last_ip)));
                 } else {
                     $this->session->set_flashdata('message', lang('auth_login_ok_welcome', array($_first_name, $_last_login)));
                 }
             } else {
                 $this->session->set_flashdata('message', lang('auth_login_ok_welcome_notime', array($_first_name)));
             }
             $_redirect = $this->data['return_to'] ? $this->data['return_to'] : $_login['homepage'];
             // --------------------------------------------------------------------------
             //	Generate an event for this log in
             create_event('did_log_in', $_login['user_id'], 0, NULL, array('method' => 'api'));
             // --------------------------------------------------------------------------
             //	Login failed
             $_out['goto'] = site_url($_redirect);
         }
     } else {
         //	Login failed
         $_out['status'] = 401;
         $_out['error'] = $this->auth_model->get_errors();
         $_out['code'] = 1;
     }
     // --------------------------------------------------------------------------
     $this->_out($_out);
 }
开发者ID:nailsapp,项目名称:module-api,代码行数:63,代码来源:auth.php


示例13: mysupport_relative_time

/**
 * Get the relative time of when a thread was solved.
 *
 * @param int Timestamp of when the thread was solved.
 * @return string Relative time of when the thread was solved.
**/
function mysupport_relative_time($statustime)
{
    global $lang;
    $lang->load("mysupport");
    $time = TIME_NOW - $statustime;
    if ($time <= 60) {
        return $lang->mysupport_just_now;
    } else {
        $options = array();
        if ($time >= 864000) {
            $options['hours'] = false;
            $options['minutes'] = false;
            $options['seconds'] = false;
        }
        return nice_time($time) . " " . $lang->mysupport_ago;
    }
}
开发者ID:myWebDev,项目名称:MySupport,代码行数:23,代码来源:mysupport.php


示例14: with_hashes

 /**
  * Log a user in using hashes of their user ID and password; easy way of
  * automatically logging a user in from the likes of an email.
  *
  * @access	public
  * @param	none
  * @return	void
  **/
 public function with_hashes()
 {
     if (!$this->config->item('auth_enable_hashed_login')) {
         show_404();
     }
     // --------------------------------------------------------------------------
     $_hash['id'] = $this->uri->segment(4);
     $_hash['pw'] = $this->uri->segment(5);
     if (empty($_hash['id']) || empty($_hash['pw'])) {
         show_error($lang['auth_with_hashes_incomplete_creds']);
     }
     // --------------------------------------------------------------------------
     /**
      * If the user is already logged in we need to check to see if we check to see if they are
      * attempting to login as themselves, if so we redirect, otherwise we log them out and try
      * again using the hashes.
      *
      **/
     if ($this->user_model->is_logged_in()) {
         if (md5(active_user('id')) == $_hash['id']) {
             //	We are attempting to log in as who we're already logged in as, redirect normally
             if ($this->data['return_to']) {
                 redirect($this->data['return_to']);
             } else {
                 //	Nowhere to go? Send them to their default homepage
                 redirect(active_user('group_homepage'));
             }
         } else {
             //	We are logging in as someone else, log the current user out and try again
             $this->auth_model->logout();
             redirect(preg_replace('/^\\//', '', $_SERVER['REQUEST_URI']));
         }
         return;
     }
     // --------------------------------------------------------------------------
     /**
      * The active user is a guest, we must look up the hashed user and log them in
      * if all is ok otherwise we report an error.
      *
      **/
     $_user = $this->user_model->get_by_hashes($_hash['id'], $_hash['pw']);
     // --------------------------------------------------------------------------
     if ($_user) {
         //	User was verified, log the user in
         $this->user_model->set_login_data($_user->id);
         // --------------------------------------------------------------------------
         //	Say hello
         if ($_user->last_login) {
             $this->load->helper('date');
             $_last_login = $this->config->item('auth_show_nicetime_on_login') ? nice_time(strtotime($_user->last_login)) : user_datetime($_user->last_login);
             if ($this->config->item('auth_show_last_ip_on_login')) {
                 $this->session->set_flashdata('message', lang('auth_login_ok_welcome_with_ip', array($_user->first_name, $_last_login, $_user->last_ip)));
             } else {
                 $this->session->set_flashdata('message', lang('auth_login_ok_welcome', array($_user->first_name, $_user->last_login)));
             }
         } else {
             $this->session->set_flashdata('message', lang('auth_login_ok_welcome_notime', array($_user->first_name)));
         }
         // --------------------------------------------------------------------------
         //	Update their last login
         $this->user_model->update_last_login($_user->id);
         // --------------------------------------------------------------------------
         //	Redirect user
         if ($this->data['return_to'] != site_url()) {
             //	We have somewhere we want to go
             redirect($this->data['return_to']);
         } else {
             //	Nowhere to go? Send them to their default homepage
             redirect($_user->group_homepage);
         }
     } else {
         //	Bad lookup, invalid hash.
         $this->session->set_flashdata('error', lang('auth_with_hashes_autologin_fail'));
         redirect($this->data['return_to']);
     }
 }
开发者ID:nailsapp,项目名称:module-auth,代码行数:84,代码来源:login.php


示例15: _orders_view

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP nicecase函数代码示例发布时间:2022-05-15
下一篇:
PHP nice_length函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap