本文整理汇总了PHP中my_setcookie函数的典型用法代码示例。如果您正苦于以下问题:PHP my_setcookie函数的具体用法?PHP my_setcookie怎么用?PHP my_setcookie使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了my_setcookie函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login_func
function login_func($xmlrpc_params)
{
global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $mobiquo_config, $user, $register;
$lang->load("member");
$input = Tapatalk_Input::filterXmlInput(array('username' => Tapatalk_Input::STRING, 'password' => Tapatalk_Input::STRING, 'anonymous' => Tapatalk_Input::INT, 'push' => Tapatalk_Input::STRING), $xmlrpc_params);
$logins = login_attempt_check(1);
$login_text = '';
if (!username_exists($input['username'])) {
my_setcookie('loginattempts', $logins + 1);
$status = 2;
$response = new xmlrpcval(array('result' => new xmlrpcval(0, 'boolean'), 'result_text' => new xmlrpcval(strip_tags($lang->error_invalidpworusername), 'base64'), 'status' => new xmlrpcval($status, 'string')), 'struct');
return new xmlrpcresp($response);
}
$query = $db->simple_select("users", "loginattempts", "LOWER(username)='" . my_strtolower($input['username_esc']) . "'", array('limit' => 1));
$loginattempts = $db->fetch_field($query, "loginattempts");
$errors = array();
$user = validate_password_from_username($input['username'], $input['password']);
$correct = false;
if (!$user['uid']) {
if (validate_email_format($input['username'])) {
$mybb->settings['username_method'] = 1;
$user = validate_password_from_username($input['username'], $input['password']);
}
if (!$user['uid']) {
my_setcookie('loginattempts', $logins + 1);
$db->update_query("users", array('loginattempts' => 'loginattempts+1'), "LOWER(username) = '" . my_strtolower($input['username_esc']) . "'", 1, true);
if ($mybb->settings['failedlogincount'] != 0 && $mybb->settings['failedlogintext'] == 1) {
$login_text = $lang->sprintf($lang->failed_login_again, $mybb->settings['failedlogincount'] - $logins);
}
$errors[] = $lang->error_invalidpworusername . $login_text;
} else {
$correct = true;
}
} else {
$correct = true;
}
if (!empty($errors)) {
return xmlrespfalse(implode(" :: ", $errors));
} else {
if ($correct) {
$register = 0;
return tt_login_success();
}
}
return xmlrespfalse("Invalid login details");
}
示例2: set_activity
public function set_activity()
{
return my_setcookie('inferno_wait', TIME_NOW + $this->settings['inferno_shoutbox_flood']);
}
示例3: LoginDataHandler
$loginhandler = new LoginDataHandler("get");
if ($mybb->get_input('quick_password') && $mybb->get_input('quick_username')) {
$mybb->input['password'] = $mybb->get_input('quick_password');
$mybb->input['username'] = $mybb->get_input('quick_username');
$mybb->input['remember'] = $mybb->get_input('quick_remember');
}
$user = array('username' => $mybb->get_input('username'), 'password' => $mybb->get_input('password'), 'remember' => $mybb->get_input('remember'), 'imagestring' => $mybb->get_input('imagestring'));
$options = array('fields' => 'loginattempts', 'username_method' => (int) $mybb->settings['username_method']);
$user_loginattempts = get_user_by_username($user['username'], $options);
$user['loginattempts'] = (int) $user_loginattempts['loginattempts'];
$loginhandler->set_data($user);
$validated = $loginhandler->validate_login();
if (!$validated) {
$mybb->input['action'] = "login";
$mybb->request_method = "get";
my_setcookie('loginattempts', $logins + 1);
$db->update_query("users", array('loginattempts' => 'loginattempts+1'), "uid='" . (int) $loginhandler->login_data['uid'] . "'", 1, true);
$errors = $loginhandler->get_friendly_errors();
$user['loginattempts'] = (int) $loginhandler->login_data['loginattempts'];
// If we need a captcha set it here
if ($mybb->settings['failedcaptchalogincount'] > 0 && ($user['loginattempts'] > $mybb->settings['failedcaptchalogincount'] || (int) $mybb->cookies['loginattempts'] > $mybb->settings['failedcaptchalogincount'])) {
$do_captcha = true;
$correct = $loginhandler->captcha_verified;
}
} else {
if ($validated && $loginhandler->captcha_verified == true) {
// Successful login
if ($loginhandler->login_data['coppauser']) {
error($lang->error_awaitingcoppa);
}
$loginhandler->complete_login();
示例4: array
$db->update_query("adminoptions", array("recovery_codes" => $db->escape_string(my_serialize($ncodes))), "uid='{$mybb->user['uid']}'");
if (count($ncodes) == 0) {
flash_message($lang->my2fa_no_codes, "error");
}
}
// Validate the code
require_once MYBB_ROOT . "inc/3rdparty/2fa/GoogleAuthenticator.php";
$auth = new PHPGangsta_GoogleAuthenticator();
$test = $auth->verifyCode($admin_options['authsecret'], $mybb->get_input('code'));
// Either the code was okay or it was a recovery code
if ($test === true || $recovery === true) {
// Correct code -> session authenticated
$db->update_query("adminsessions", array("authenticated" => 1), "sid='" . $db->escape_string($mybb->cookies['adminsid']) . "'");
$admin_session['authenticated'] = 1;
$db->update_query("adminoptions", array("loginattempts" => 0, "loginlockoutexpiry" => 0), "uid='{$mybb->user['uid']}'");
my_setcookie('acploginattempts', 0);
// post would result in an authorization code mismatch error
$mybb->request_method = "get";
} else {
// Wrong code -> close session (aka logout)
$db->delete_query("adminsessions", "sid='" . $db->escape_string($mybb->cookies['adminsid']) . "'");
my_unsetcookie('adminsid');
// Now test whether we need to lock this guy completly
$db->update_query("adminoptions", array("loginattempts" => "loginattempts+1"), "uid='{$mybb->user['uid']}'", '', true);
$loginattempts = login_attempt_check_acp($mybb->user['uid'], true);
// Have we attempted too many times?
if ($loginattempts['loginattempts'] > 0) {
// Have we set an expiry yet?
if ($loginattempts['loginlockoutexpiry'] == 0) {
$db->update_query("adminoptions", array("loginlockoutexpiry" => TIME_NOW + (int) $mybb->settings['loginattemptstimeout'] * 60), "uid='{$mybb->user['uid']}'");
}
示例5: error
}
}
}
if (count($errors) > 0) {
error($errors[0]);
}
}
if ($mybb->input['action'] == "do_password" && $mybb->request_method == "post") {
$errors = array();
$plugins->run_hooks("usercp_do_password_start");
if (!$verify_result && !validate_password_from_uid($mybb->user['uid'], $mybb->input['oldpassword'])) {
$errors[] = $lang->error_invalidpassword;
} else {
// Set up user handler.
require_once "inc/datahandlers/user.php";
$userhandler = new UserDataHandler("update");
$user = array("uid" => $mybb->user['uid'], "password" => $mybb->input['password'], "password2" => $mybb->input['password2']);
$userhandler->set_data($user);
if (!$userhandler->validate_user()) {
$errors = $userhandler->get_friendly_errors();
} else {
$userhandler->update_user();
my_setcookie("mybbuser", $mybb->user['uid'] . "_" . $userhandler->data['loginkey']);
$plugins->run_hooks("usercp_do_password_end");
$verify_result = true;
}
}
if (count($errors) > 0) {
error($errors[0]);
}
}
示例6: my_unsetcookie
if ($mybb->get_input('quoted_ids') == "all") {
my_unsetcookie("multiquote");
} else {
$quoted_ids = explode("|", $mybb->get_input('quoted_ids'));
$multiquote = explode("|", $mybb->cookies['multiquote']);
if (is_array($multiquote) && is_array($quoted_ids)) {
foreach ($multiquote as $key => $quoteid) {
// If this ID was quoted, remove it from the multiquote list
if (in_array($quoteid, $quoted_ids)) {
unset($multiquote[$key]);
}
}
// Still have an array - set the new cookie
if (is_array($multiquote)) {
$new_multiquote = implode(",", $multiquote);
my_setcookie("multiquote", $new_multiquote);
} else {
my_unsetcookie("multiquote");
}
}
}
}
$plugins->run_hooks("newreply_do_newreply_end");
// This was a post made via the ajax quick reply - we need to do some special things here
if ($mybb->get_input('ajax', MyBB::INPUT_INT)) {
// Visible post
if ($visible == 1) {
// Set post counter
$postcounter = $thread['replies'] + 1;
if (is_moderator($fid, "canviewunapprove")) {
$postcounter += $thread['unapprovedposts'];
示例7: extendinline
function extendinline($id, $type)
{
global $mybb;
my_setcookie("inlinemod_{$type}{$id}", '', TIME_NOW + 3600);
my_setcookie("inlinemod_{$type}{$id_removed}", '', TIME_NOW + 3600);
}
示例8: error
// Load Limiting
if ($mybb->usergroup['cancp'] != 1 && $mybb->settings['load'] > 0 && ($load = get_server_load()) && $load != $lang->unknown && $load > $mybb->settings['load']) {
// User is not an administrator and the load limit is higher than the limit, show an error
error($lang->error_loadlimit);
}
// If there is a valid referrer in the URL, cookie it
if (!$mybb->user['uid'] && $mybb->settings['usereferrals'] == 1 && (isset($mybb->input['referrer']) || isset($mybb->input['referrername']))) {
if (isset($mybb->input['referrername'])) {
$condition = "username='" . $db->escape_string($mybb->input['referrername']) . "'";
} else {
$condition = "uid='" . intval($mybb->input['referrer']) . "'";
}
$query = $db->simple_select("users", "uid", $condition, array('limit' => 1));
$referrer = $db->fetch_array($query);
if ($referrer['uid']) {
my_setcookie("mybb[referrer]", $referrer['uid']);
}
}
if ($mybb->usergroup['canview'] != 1) {
// Check pages allowable even when not allowed to view board
$allowable_actions = array("member.php" => array("register", "do_register", "login", "do_login", "logout", "lostpw", "do_lostpw", "activate", "resendactivation", "do_resendactivation", "resetpassword"), "usercp2.php" => array("removesubscription", "removesubscriptions"));
if (!($current_page == "member.php" && in_array($mybb->input['action'], $allowable_actions['member.php'])) && !($current_page == "usercp2.php" && in_array($mybb->input['action'], $allowable_actions['usercp2.php'])) && $current_page != "captcha.php") {
error_no_permission();
}
unset($allowable_actions);
}
// work out which items the user has collapsed
$colcookie = $mybb->cookies['collapsed'];
// set up collapsable items (to automatically show them us expanded)
if ($colcookie) {
$col = explode("|", $colcookie);
示例9: login
/**
* Logins an user by adding a cookie into his browser and updating his session
*/
public function login($user = '')
{
global $mybb, $session, $db;
if (!$user) {
$user = $mybb->user;
}
if (!$user['uid'] or !$user['loginkey'] or !$session) {
return false;
}
// Delete all the old sessions
$db->delete_query("sessions", "ip='" . $db->escape_string($session->ipaddress) . "' and sid != '" . $session->sid . "'");
// Create a new session
$db->update_query("sessions", array("uid" => $user['uid']), "sid='" . $session->sid . "'");
// Set up the login cookies
my_setcookie("mybbuser", $user['uid'] . "_" . $user['loginkey'], null, true);
my_setcookie("sid", $session->sid, -1, true);
return true;
}
示例10: eval
$modann = '';
}
$plugins->run_hooks("forumdisplay_announcement");
eval("\$announcements .= \"" . $templates->get("forumdisplay_announcements_announcement") . "\";");
$bgcolor = alt_trow();
}
if ($announcements) {
eval("\$announcementlist = \"" . $templates->get("forumdisplay_announcements") . "\";");
$shownormalsep = true;
}
if (empty($cookie)) {
// Clean up cookie crumbs
my_setcookie('mybb[announcements]', 0, TIME_NOW - 60 * 60 * 24 * 365);
} else {
if (!empty($cookie)) {
my_setcookie("mybb[announcements]", addslashes(my_serialize($cookie)), -1);
}
}
} else {
$announcementlist = '';
}
$tids = $threadcache = array();
$icon_cache = $cache->read("posticons");
if ($fpermissions['canviewthreads'] != 0) {
$plugins->run_hooks("forumdisplay_get_threads");
// Start Getting Threads
$query = $db->query("\n\t\tSELECT t.*, {$ratingadd}t.username AS threadusername, u.username\n\t\tFROM " . TABLE_PREFIX . "threads t\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid = t.uid)\n\t\tWHERE t.fid='{$fid}' {$tuseronly} {$tvisibleonly} {$datecutsql2} {$prefixsql2}\n\t\tORDER BY t.sticky DESC, {$t}{$sortfield} {$sortordernow} {$sortfield2}\n\t\tLIMIT {$start}, {$perpage}\n\t");
$ratings = false;
$moved_threads = array();
while ($thread = $db->fetch_array($query)) {
$threadcache[$thread['tid']] = $thread;
示例11: gomobile_switch_version
function gomobile_switch_version()
{
global $db, $lang, $mybb;
if ($mybb->input['action'] != "switch_version") {
return false;
}
$url = "index.php";
if (isset($_SERVER['HTTP_REFERER'])) {
$url = htmlentities($_SERVER['HTTP_REFERER']);
}
if (md5($mybb->post_code) != $mybb->input['my_post_key']) {
redirect($url, $lang->invalid_post_code);
}
if ($mybb->input['do'] == "full") {
// Disable the mobile theme
my_setcookie("gomobile", "disabled", -1);
} elseif ($mybb->input['do'] == "clear") {
// Clear the mobile theme cookie
my_setcookie("gomobile", "nothing", -1);
} else {
// Assume we're wanting to switch to the mobile version
my_setcookie("gomobile", "force", -1);
}
$lang->load("gomobile");
redirect($url, $lang->gomobile_switched_version);
}
示例12: login
/**
* Log the user into MyBB with their MC credentials.
* Must be authenticated with authenticate() first!
*
* @access public
* @param $username
* @return bool
*/
public function login($username)
{
global $mybb, $db, $session;
if (!isset($username)) {
$username = $this->getUsername();
}
$q = $db->simple_select('users', 'uid,loginkey', "mcc_username = '{$username}'");
if ($db->num_rows($q) == 1) {
$user = $db->fetch_array($q);
if (!$user['uid']) {
return false;
}
// Delete all the old sessions from user's IP address
$db->delete_query('sessions', "ip='" . $db->escape_string($session->ipaddress) . "' AND sid != '{$session->sid}'");
// Create a new session
$db->update_query('sessions', array('uid' => $user['uid']), "sid='{$session->sid}'");
// Set login cookies
my_setcookie('mybbuser', $user['uid'] . '_' . $user['loginkey'], null, true);
my_setcookie('sid', $session->sid, -1, true);
return true;
}
return false;
}
示例13: complete_login
/**
* @return bool true
*/
function complete_login()
{
global $plugins, $db, $mybb, $session;
$user =& $this->login_data;
$plugins->run_hooks('datahandler_login_complete_start', $this);
// Login to MyBB
my_setcookie('loginattempts', 1);
my_setcookie("sid", $session->sid, -1, true);
$ip_address = $db->escape_binary($session->packedip);
$db->delete_query("sessions", "ip = {$ip_address} AND sid != '{$session->sid}'");
$newsession = array("uid" => $user['uid']);
$db->update_query("sessions", $newsession, "sid = '{$session->sid}'");
$db->update_query("users", array("loginattempts" => 1), "uid = '{$user['uid']}'");
$remember = null;
if (!isset($mybb->input['remember']) || $mybb->input['remember'] != "yes") {
$remember = -1;
}
my_setcookie("mybbuser", $user['uid'] . "_" . $user['loginkey'], $remember, true);
if ($this->captcha !== false) {
$this->captcha->invalidate_captcha();
}
$plugins->run_hooks('datahandler_login_complete_end', $this);
return true;
}
示例14: loginconvert_convert
function loginconvert_convert()
{
global $mybb, $db, $lang, $session, $plugins, $inline_errors, $errors;
if ($mybb->input['action'] != "do_login" || $mybb->request_method != "post") {
return;
}
// Checks to make sure the user can login; they haven't had too many tries at logging in.
// Is a fatal call if user has had too many tries
$logins = login_attempt_check();
$login_text = '';
// Did we come from the quick login form?
if ($mybb->input['quick_login'] == "1" && $mybb->input['quick_password'] && $mybb->input['quick_username']) {
$mybb->input['password'] = $mybb->input['quick_password'];
$mybb->input['username'] = $mybb->input['quick_username'];
}
if (!username_exists($mybb->input['username'])) {
my_setcookie('loginattempts', $logins + 1);
error($lang->error_invalidpworusername . $login_text);
}
$query = $db->simple_select("users", "loginattempts", "LOWER(username)='" . $db->escape_string(my_strtolower($mybb->input['username'])) . "'", array('limit' => 1));
$loginattempts = $db->fetch_field($query, "loginattempts");
$errors = array();
$user = loginconvert_validate_password_from_username($mybb->input['username'], $mybb->input['password']);
if (!$user['uid']) {
my_setcookie('loginattempts', $logins + 1);
$db->write_query("UPDATE " . TABLE_PREFIX . "users SET loginattempts=loginattempts+1 WHERE LOWER(username) = '" . $db->escape_string(my_strtolower($mybb->input['username'])) . "'");
$mybb->input['action'] = "login";
$mybb->input['request_method'] = "get";
if ($mybb->settings['failedlogintext'] == 1) {
$login_text = $lang->sprintf($lang->failed_login_again, $mybb->settings['failedlogincount'] - $logins);
}
$errors[] = $lang->error_invalidpworusername . $login_text;
} else {
$correct = true;
}
if ($loginattempts > 3 || intval($mybb->cookies['loginattempts']) > 3) {
// Show captcha image for guests if enabled
if ($mybb->settings['captchaimage'] == 1 && function_exists("imagepng") && !$mybb->user['uid']) {
// If previewing a post - check their current captcha input - if correct, hide the captcha input area
if ($mybb->input['imagestring']) {
$imagehash = $db->escape_string($mybb->input['imagehash']);
$imagestring = $db->escape_string($mybb->input['imagestring']);
$query = $db->simple_select("captcha", "*", "imagehash='{$imagehash}' AND imagestring='{$imagestring}'");
$imgcheck = $db->fetch_array($query);
if ($imgcheck['dateline'] > 0) {
$correct = true;
} else {
$db->delete_query("captcha", "imagehash='{$imagehash}'");
$errors[] = $lang->error_regimageinvalid;
}
} else {
if ($mybb->input['quick_login'] == 1 && $mybb->input['quick_password'] && $mybb->input['quick_username']) {
$errors[] = $lang->error_regimagerequired;
} else {
$errors[] = $lang->error_regimagerequired;
}
}
}
$do_captcha = true;
}
if (!empty($errors)) {
$mybb->input['action'] = "login";
$mybb->input['request_method'] = "get";
$inline_errors = inline_error($errors);
} else {
if ($correct) {
if ($user['coppauser']) {
error($lang->error_awaitingcoppa);
}
my_setcookie('loginattempts', 1);
$db->delete_query("sessions", "ip='" . $db->escape_string($session->ipaddress) . "' AND sid != '" . $session->sid . "'");
$newsession = array("uid" => $user['uid']);
$db->update_query("sessions", $newsession, "sid='" . $session->sid . "'");
$db->update_query("users", array("loginattempts" => 1), "uid='{$user['uid']}'");
my_setcookie("mybbuser", $user['uid'] . "_" . $user['loginkey'], null, true);
my_setcookie("sid", $session->sid, -1, true);
$plugins->run_hooks("member_do_login_end");
if ($mybb->input['url'] != "" && my_strpos(basename($mybb->input['url']), 'member.php') === false) {
if ((my_strpos(basename($mybb->input['url']), 'newthread.php') !== false || my_strpos(basename($mybb->input['url']), 'newreply.php') !== false) && my_strpos($mybb->input['url'], '&processed=1') !== false) {
$mybb->input['url'] = str_replace('&processed=1', '', $mybb->input['url']);
}
$mybb->input['url'] = str_replace('&', '&', $mybb->input['url']);
// Redirect to the URL if it is not member.php
redirect(htmlentities($mybb->input['url']), $lang->redirect_loggedin);
} else {
redirect("index.php", $lang->redirect_loggedin);
}
} else {
$mybb->input['action'] = "login";
$mybb->input['request_method'] = "get";
}
}
}
示例15: array
$vote_options = array();
if ($mybb->user['uid']) {
$query = $db->simple_select("pollvotes", "vid,voteoption", "uid='" . $mybb->user['uid'] . "' AND pid='" . $poll['pid'] . "'");
while ($voteoption = $db->fetch_array($query)) {
$vote_options[$voteoption['vid']] = $voteoption['voteoption'];
}
} elseif (isset($mybb->cookies['pollvotes'][$poll['pid']])) {
// for Guests, we simply see if they've got the cookie
$vote_options = explode(',', $mybb->cookies['pollvotes'][$poll['pid']]);
}
if (empty($vote_options)) {
error($lang->error_notvoted);
} else {
if (!$mybb->user['uid']) {
// clear cookie for Guests
my_setcookie("pollvotes[{$poll['pid']}]", "");
}
}
// Note, this is not thread safe!
$votesarray = explode("||~|~||", $poll['votes']);
if (count($votesarray) > $poll['numoptions']) {
$votesarray = array_slice(0, $poll['numoptions']);
}
if ($poll['multiple'] == 1) {
foreach ($vote_options as $vote) {
if (isset($votesarray[$vote - 1])) {
--$votesarray[$vote - 1];
--$poll['numvotes'];
}
}
} else {