Пример #1
0
    $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;
Пример #2
0
 $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']);
Пример #3
0
 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');
                     if ($this->data['num_questions'] + $this->data['num_custom_questions'] <= 0) {
                         show_fatal_error('Two-factor auth is enabled, but no questions available', 'A user tried to set security questions but there are no questions available for them to choose. Please ensure auth.php is configured correctly.');
                     }
                     if ($this->input->post()) {
                         $this->load->library('form_validation');
                         for ($i = 0; $i < $this->data['num_questions']; $i++) {
                             $this->form_validation->set_rules('question[' . $i . '][question]', '', 'xss_clean|required|is_natural_no_zero');
                             $this->form_validation->set_rules('question[' . $i . '][answer]', '', 'xss_clean|trim|required');
                         }
                         for ($i = 0; $i < $this->data['num_custom_questions']; $i++) {
                             $this->form_validation->set_rules('custom_question[' . $i . '][question]', '', 'xss_clean|trim|required');
                             $this->form_validation->set_rules('custom_question[' . $i . '][answer]', '', 'xss_clean|trim|required');
                         }
                         $this->form_validation->set_message('required', lang('fv_required'));
                         $this->form_validation->set_message('is_natural_no_zero', lang('fv_required'));
                         if ($this->form_validation->run()) {
                             //	Make sure that we have different questions
                             $_question_index = array();
                             $_question = (array) $this->input->post('question');
                             $_error = FALSE;
                             foreach ($_question as $q) {
                                 if (array_search($q['question'], $_question_index) === FALSE) {
                                     $_question_index[] = $q['question'];
                                 } else {
                                     $_error = TRUE;
                                     break;
                                 }
                             }
                             $_question_index = array();
                             $_question = (array) $this->input->post('custom_question');
                             foreach ($_question as $q) {
                                 if (array_search($q['question'], $_question_index) === FALSE) {
                                     $_question_index[] = $q['question'];
                                 } else {
                                     $_error = TRUE;
                                     break;
                                 }
                             }
                             if (!$_error) {
                                 //	Good arrows. Save questions
                                 $_data = array();
                                 if ($this->input->post('question')) {
                                     foreach ($this->input->post('question') as $q) {
                                         $_temp = new stdClass();
                                         $_temp->question = isset($this->data['questions'][$q['question'] - 1]) ? $this->data['questions'][$q['question'] - 1] : NULL;
                                         $_temp->answer = $q['answer'];
                                         $_data[] = $_temp;
                                     }
                                 }
                                 if ($this->input->post('custom_question')) {
                                     foreach ((array) $this->input->post('custom_question') as $q) {
                                         $_temp = new stdClass();
                                         $_temp->question = trim($q['question']);
                                         $_temp->answer = $q['answer'];
                                         $_data[] = $_temp;
                                     }
                                 }
                                 if ($this->user_model->set_security_questions($_user->id, $_data)) {
                                     //	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_question_set_fail') . ' ' . $this->user_model->last_error();
                                 }
                             } else {
                                 $this->data['error'] = lang('auth_twofactor_question_unique');
                             }
                         } else {
                             $this->data['error'] = lang('fv_there_were_errors');
                         }
                     }
                     //	No questions, request they set them
                     $this->data['page']->title = lang('auth_twofactor_question_set_title');
                     $this->load->view('structure/header', $this->data);
                     $this->load->view('auth/security_question/set', $this->data);
                     $this->load->view('structure/footer', $this->data);
                 }
             }
         } else {
             $this->session->set_flashdata('error', lang('auth_twofactor_token_unverified'));
             $_query = array();
             $_query['return_to'] = $_return_to;
             $_query['remember'] = $_remember;
             $_query = array_filter($_query);
             if ($_query) {
                 $_query = '?' . http_build_query($_query);
             } else {
                 $_query = '';
             }
             redirect('auth/login' . $_query);
         }
     } else {
         show_404();
     }
 }
Пример #4
0
    </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/>
Пример #5
0
		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;
}
Пример #6
0
     }
 }
 $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();
Пример #7
0
 /**
  * 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');
             }
         }
         // --------------------------------------------------------------------------
         //	Set data
         $this->data['page']->title = lang('auth_title_reset');
         $this->data['auth'] = new stdClass();
         $this->data['auth']->id = $id;
         $this->data['auth']->hash = $hash;
         $this->data['return_to'] = $this->input->get('return_to');
         $this->data['remember'] = $this->input->get('remember');
         $this->data['message'] = lang('auth_forgot_temp_message');
         // --------------------------------------------------------------------------
         //	Load the views
         $this->load->view('structure/header', $this->data);
         $this->load->view('auth/password/change_temp', $this->data);
         $this->load->view('structure/footer', $this->data);
         return;
     }
     // --------------------------------------------------------------------------
     show_404();
 }
Пример #8
0
function get_user_info_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $parser, $displaygroupfields;
    $lang->load("member");
    $input = Tapatalk_Input::filterXmlInput(array('user_name' => Tapatalk_Input::STRING, 'user_id' => Tapatalk_Input::INT), $xmlrpc_params);
    if ($mybb->usergroup['canviewprofiles'] == 0) {
        error_no_permission();
    }
    if (isset($input['user_id']) && !empty($input['user_id'])) {
        $uid = $input['user_id'];
    } elseif (!empty($input['user_name'])) {
        $query = $db->simple_select("users", "uid", "username='******'user_name_esc']}'");
        $uid = $db->fetch_field($query, "uid");
    } else {
        $uid = $mybb->user['uid'];
    }
    if ($mybb->user['uid'] != $uid) {
        $memprofile = get_user($uid);
    } else {
        $memprofile = $mybb->user;
    }
    if (!$memprofile['uid']) {
        error($lang->error_nomember);
    }
    // Get member's permissions
    $memperms = user_permissions($memprofile['uid']);
    if (!$memprofile['displaygroup']) {
        $memprofile['displaygroup'] = $memprofile['usergroup'];
    }
    // Grab the following fields from the user's displaygroup
    $displaygroupfields = array("title", "usertitle", "stars", "starimage", "image", "usereputationsystem");
    $displaygroup = usergroup_displaygroup($memprofile['displaygroup']);
    // Get the user title for this user
    unset($usertitle);
    unset($stars);
    if (trim($memprofile['usertitle']) != '') {
        // User has custom user title
        $usertitle = $memprofile['usertitle'];
    } elseif (trim($displaygroup['usertitle']) != '') {
        // User has group title
        $usertitle = $displaygroup['usertitle'];
    } else {
        // No usergroup title so get a default one
        $query = $db->simple_select("usertitles", "*", "", array('order_by' => 'posts', 'order_dir' => 'DESC'));
        while ($title = $db->fetch_array($query)) {
            if ($memprofile['postnum'] >= $title['posts']) {
                $usertitle = $title['title'];
                $stars = $title['stars'];
                $starimage = $title['starimage'];
                break;
            }
        }
    }
    // User is currently online and this user has permissions to view the user on the WOL
    $timesearch = TIME_NOW - $mybb->settings['wolcutoffmins'] * 60;
    $query = $db->simple_select("sessions", "location,nopermission", "uid='{$uid}' AND time>'{$timesearch}'", array('order_by' => 'time', 'order_dir' => 'DESC', 'limit' => 1));
    $session = $db->fetch_array($query);
    if (($memprofile['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $memprofile['uid'] == $mybb->user['uid']) && !empty($session)) {
        // Fetch their current location
        $lang->load("online");
        require_once MYBB_ROOT . "inc/functions_online.php";
        $activity = fetch_wol_activity($session['location'], $session['nopermission']);
        /*unset($activity['tid']);
          unset($activity['fid']);
          unset($activity['pid']);
          unset($activity['eid']);
          unset($activity['aid']);*/
        $location = strip_tags(build_friendly_wol_location($activity));
        $location_time = my_date($mybb->settings['timeformat'], $memprofile['lastactive']);
        $online = true;
    } else {
        $online = false;
    }
    // Get custom fields start
    $custom_fields_list = array();
    if ($memprofile['birthday']) {
        $membday = explode("-", $memprofile['birthday']);
        if ($memprofile['birthdayprivacy'] != 'none') {
            if ($membday[0] && $membday[1] && $membday[2]) {
                $lang->membdayage = $lang->sprintf($lang->membdayage, get_age($memprofile['birthday']));
                if ($membday[2] >= 1970) {
                    $w_day = date("l", mktime(0, 0, 0, $membday[1], $membday[0], $membday[2]));
                    $membday = format_bdays($mybb->settings['dateformat'], $membday[1], $membday[0], $membday[2], $w_day);
                } else {
                    $bdayformat = fix_mktime($mybb->settings['dateformat'], $membday[2]);
                    $membday = mktime(0, 0, 0, $membday[1], $membday[0], $membday[2]);
                    $membday = date($bdayformat, $membday);
                }
                $membdayage = $lang->membdayage;
            } elseif ($membday[2]) {
                $membday = mktime(0, 0, 0, 1, 1, $membday[2]);
                $membday = date("Y", $membday);
                $membdayage = '';
            } else {
                $membday = mktime(0, 0, 0, $membday[1], $membday[0], 0);
                $membday = date("F j", $membday);
                $membdayage = '';
            }
        }
        if ($memprofile['birthdayprivacy'] == 'age') {
            $membday = $lang->birthdayhidden;
        } else {
            if ($memprofile['birthdayprivacy'] == 'none') {
                $membday = $lang->birthdayhidden;
                $membdayage = '';
            }
        }
        $custom_fields_list[] = new xmlrpcval(array('name' => new xmlrpcval(basic_clean($lang->date_of_birth), 'base64'), 'value' => new xmlrpcval(basic_clean("{$membday} {$membdayage}"), 'base64')), 'struct');
    }
    // thank you/like field
    global $mobiquo_config;
    $prefix = $mobiquo_config['thlprefix'];
    if ($mybb->settings[$prefix . 'enabled'] == "1") {
        $lang->load("thankyoulike");
        if ($mybb->settings[$prefix . 'thankslike'] == "like") {
            $lang->tyl_total_tyls_given = $lang->tyl_total_likes_given;
            $lang->tyl_total_tyls_rcvd = $lang->tyl_total_likes_rcvd;
        } else {
            if ($mybb->settings[$prefix . 'thankslike'] == "thanks") {
                $lang->tyl_total_tyls_given = $lang->tyl_total_thanks_given;
                $lang->tyl_total_tyls_rcvd = $lang->tyl_total_thanks_rcvd;
            }
        }
        $daysreg = (TIME_NOW - $memprofile['regdate']) / (24 * 3600);
        $tylpd = $memprofile['tyl_unumtyls'] / $daysreg;
        $tylpd = round($tylpd, 2);
        if ($tylpd > $memprofile['tyl_unumtyls']) {
            $tylpd = $memprofile['tyl_unumtyls'];
        }
        $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}'");
    $userfields = $db->fetch_array($query);
    if ($mybb->usergroup['cancp'] == 1 || $mybb->usergroup['issupermod'] == 1 || $mybb->usergroup['canmodcp'] == 1) {
        $field_hidden = '1=1';
    } else {
        $field_hidden = "hidden=0";
    }
    $query = $db->simple_select("profilefields", "*", "{$field_hidden}", array('order_by' => 'disporder'));
    while ($customfield = $db->fetch_array($query)) {
        $thing = explode("\n", $customfield['type'], "2");
        $type = trim($thing[0]);
        $field = "fid{$customfield['fid']}";
        $useropts = explode("\n", $userfields[$field]);
        $customfieldval = $comma = '';
        if (is_array($useropts) && ($type == "multiselect" || $type == "checkbox")) {
            $customfieldval = $userfields[$field];
        } else {
            $customfieldval = $parser->parse_badwords($userfields[$field]);
        }
        $customfield['name'] = htmlspecialchars_uni($customfield['name']);
        if ($customfieldval) {
            addCustomField($customfield['name'], $customfieldval, $custom_fields_list);
        }
    }
    if ($memprofile['signature'] && ($memprofile['suspendsignature'] == 0 || $memprofile['suspendsigtime'] < TIME_NOW)) {
        $sig_parser = array("allow_html" => $mybb->settings['sightml'], "allow_mycode" => $mybb->settings['sigmycode'], "allow_smilies" => $mybb->settings['sigsmilies'], "allow_imgcode" => $mybb->settings['sigimgcode'], "me_username" => $memprofile['username'], "filter_badwords" => 1);
        $memprofile['signature'] = $parser->parse_message($memprofile['signature'], $sig_parser);
        $lang->users_signature = $lang->sprintf($lang->users_signature, $memprofile['username']);
        addCustomField($lang->users_signature, $memprofile['signature'], $custom_fields_list);
    }
    // Get custom fields end
    $query = $db->simple_select("banned", "uid", "uid='{$uid}'");
    $isbanned = !!$db->fetch_field($query, "uid");
    $xmlrpc_user_info = array('user_id' => new xmlrpcval($memprofile['uid'], 'string'), 'username' => new xmlrpcval(basic_clean($memprofile['username']), 'base64'), 'user_name' => new xmlrpcval(basic_clean($memprofile['username']), 'base64'), 'user_type' => check_return_user_type($memprofile['username']), 'post_count' => new xmlrpcval($memprofile['postnum'], 'int'), 'reg_time' => new xmlrpcval(mobiquo_iso8601_encode($memprofile['regdate']), 'dateTime.iso8601'), 'timestamp_reg' => new xmlrpcval($memprofile['regdate'], 'string'), 'last_activity_time' => new xmlrpcval(mobiquo_iso8601_encode($memprofile['lastactive']), 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($memprofile['lastactive'], 'string'), 'is_online' => new xmlrpcval($online, 'boolean'), 'accept_pm' => new xmlrpcval($memprofile['receivepms'], 'boolean'), 'display_text' => new xmlrpcval($usertitle, 'base64'), 'icon_url' => new xmlrpcval(absolute_url($memprofile['avatar']), 'string'), 'current_activity' => new xmlrpcval($location, 'base64'));
    if ($mybb->usergroup['canmodcp'] == 1 && $uid != $mybb->user['uid']) {
        $xmlrpc_user_info['can_ban'] = new xmlrpcval(ture, 'boolean');
    }
    if ($isbanned) {
        $xmlrpc_user_info['is_ban'] = new xmlrpcval(ture, 'boolean');
    }
    $xmlrpc_user_info['custom_fields_list'] = new xmlrpcval($custom_fields_list, 'array');
    return new xmlrpcresp(new xmlrpcval($xmlrpc_user_info, 'struct'));
}
Пример #9
0
                 $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 {
Пример #10
0
 /**
  * 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;
 }
Пример #11
0
 /**
  * Log a user in
  *
  * @access	public
  * @param	string $identifier The identifier to use for the user lookup
  * @param	string $password The user's password
  * @param	boolean $remember Whether to 'remember' the user or not
  * @return	object
  **/
 public function login($identifier, $password, $remember = FALSE)
 {
     //	Delay execution for a moment (reduces brute force efficiently)
     if (ENVIRONMENT !== 'development') {
         usleep($this->brute_force_protection['delay']);
     }
     // --------------------------------------------------------------------------
     if (empty($identifier) || empty($password)) {
         $this->_set_error('auth_login_fail_missing_field');
         return FALSE;
     }
     // --------------------------------------------------------------------------
     //	Look up the user, how we do so depends on the login mode that the app is using
     switch (APP_NATIVE_LOGIN_USING) {
         case 'EMAIL':
             $_user = $this->user_model->get_by_email($identifier);
             break;
             // --------------------------------------------------------------------------
         // --------------------------------------------------------------------------
         case 'USERNAME':
             $_user = $this->user_model->get_by_username($identifier);
             break;
             // --------------------------------------------------------------------------
         // --------------------------------------------------------------------------
         case 'BOTH':
         default:
             $this->load->helper('email');
             if (valid_email($identifier)) {
                 $_user = $this->user_model->get_by_email($identifier);
             } else {
                 $_user = $this->user_model->get_by_username($identifier);
             }
             break;
     }
     // --------------------------------------------------------------------------
     if ($_user) {
         //	User was recognised; validate credentials
         if ($this->user_password_model->is_correct($_user->id, $password)) {
             //	Password accepted! Final checks...
             //	Suspended user?
             if ($_user->is_suspended) {
                 $this->_set_error('auth_login_fail_suspended');
                 return FALSE;
             }
             //	Exceeded login count, temporarily blocked
             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;
                 }
             }
             //	Reset user's failed login counter and allow login
             $this->user_model->reset_failed_login($_user->id);
             //	If two factor auth is enabled then don't _actually_ set login data
             //	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;
 }
Пример #12
0
 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);
 }
Пример #13
0
/**
 * 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;
    }
}
Пример #14
0
 /**
  * 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']);
     }
 }
Пример #15
0
 /**
  * View order
  *
  * @access protected
  * @param none
  * @return void
  **/
 protected function _orders_view()
 {
     if (!user_has_permission('admin.shop.orders_view')) {
         $this->session->set_flashdata('error', '<strong>Sorry,</strong> you do not have permission to view order details.');
         redirect('admin/shop/orders');
         return;
     }
     // --------------------------------------------------------------------------
     //	Fetch and check order
     $this->load->model('shop/shop_order_model');
     $this->data['order'] = $this->shop_order_model->get_by_id($this->uri->segment(5));
     if (!$this->data['order']) {
         $this->session->set_flashdata('error', '<strong>Sorry,</strong> no order exists by that ID.');
         redirect('admin/shop/orders');
         return;
     }
     // --------------------------------------------------------------------------
     //	Fulfilled?
     $this->load->helper('date');
     if ($this->data['order']->status == 'PAID') {
         if ($this->data['order']->fulfilment_status == 'UNFULFILLED') {
             $this->data['message'] = '<strong>This order has not been fulfilled; order was placed ' . nice_time(strtotime($this->data['order']->created)) . '</strong><br />Once all purchased items are marked as processed the order will be automatically marked as fulfilled.';
         } elseif (!$this->data['success']) {
             $this->data['success'] = '<strong>This order was fulfilled ' . nice_time(strtotime($this->data['order']->fulfilled)) . '</strong>';
         }
     }
     // --------------------------------------------------------------------------
     //	Set method info
     $this->data['page']->title = 'View Order &rsaquo; ' . $this->data['order']->ref;
     // --------------------------------------------------------------------------
     if ($this->input->get('is_fancybox')) {
         $this->data['header_override'] = 'structure/header/blank';
         $this->data['footer_override'] = 'structure/footer/blank';
     }
     // --------------------------------------------------------------------------
     $this->load->view('structure/header', $this->data);
     $this->load->view('admin/shop/orders/view', $this->data);
     $this->load->view('structure/footer', $this->data);
 }