예제 #1
0
    if (file_exists($searchFile)) {
        require_once $searchFile;
        break;
    }
    $searchFile = "../" . $searchFile;
}
//If it couldn't be found, try one last possible scenario: wp-content was moved above a "wordpress" folder
$searchFile = "../../../wordpress/wp-blog-header.php";
if (file_exists($searchFile)) {
    require_once $searchFile;
}
//Make sure we got it
if (!defined('WPINC')) {
    $message = "Failed to locate wp-blog-header.php.<br/>" . "If you're seeing this message, it probably means you moved your wp-content folder somewhere non-default;<br/>" . "Please open the file \"__inc_wp.php\" in the WP-FB-AutoConnect plugin directory, and specify the path to your wp-blog-header.php.";
    if (function_exists('j_die')) {
        j_die($message);
    } else {
        die($message);
    }
}
//Include the User Registration code so we can use wp_insert_user
if (!function_exists('wp_insert_user')) {
    require_once ABSPATH . WPINC . '/registration.php';
}
if (!function_exists('wp_insert_user')) {
    if (function_exists('j_die')) {
        j_die("Failed to include registration.php.");
    } else {
        die("Failed to include registration.php.");
    }
}
예제 #2
0
    $user_data['user_login'] = "******" . $fb_uid;
    $user_data['user_pass'] = nxt_generate_password();
    $user_data['user_nicename'] = sanitize_title($user_data['user_login']);
    $user_data['first_name'] = $fbuser['first_name'];
    $user_data['last_name'] = $fbuser['last_name'];
    $user_data['display_name'] = $fbuser['first_name'];
    $user_data['user_url'] = $fbuser["profile_url"];
    $user_data['user_email'] = $fbuser["email"];
    //Run a filter so the user can be modified to something different before registration
    //NOTE: If the user has selected "pretty names", this'll change FB_xxx to i.e. "John.Smith"
    $user_data = apply_filters('nxtfb_insert_user', $user_data, $fbuser);
    $user_data = apply_filters('nxtfb_inserting_user', $user_data, array('nxt_ID' => $user_login_id, 'FB_ID' => $fb_uid, 'facebook' => $facebook, 'FB_UserData' => $fbuser));
    //Insert a new user to our database and make sure it worked
    $user_login_id = nxt_insert_user($user_data);
    if (is_nxt_error($user_login_id)) {
        j_die("Error: nxt_insert_user failed!<br/><br/>" . "If you get this error while running a nxtclass MultiSite installation, it means you'll need to purchase the <a href=\"{$jfb_homepage}#premium\">premium version</a> of this plugin to enable full MultiSite support.<br/><br/>" . "If you're <u><i>not</i></u> using MultiSite, please report this bug to the plugin author on the support page <a href=\"{$jfb_homepage}#feedback\">here</a>.<br /><br />" . "Error message: " . (function_exists(array(&$user_login_id, 'get_error_message')) ? $user_login_id->get_error_message() : "Undefined") . "<br />" . "nxt_ALLOW_MULTISITE: " . (defined('nxt_ALLOW_MULTISITE') ? constant('nxt_ALLOW_MULTISITE') : "Undefined") . "<br />" . "is_multisite: " . (function_exists('is_multisite') ? is_multisite() : "Undefined"));
    }
    //Success! Notify the site admin.
    $user_login_name = $user_data['user_login'];
    nxt_new_user_notification($user_login_name);
    //Run an action so i.e. usermeta can be added to a user after registration
    do_action('nxtfb_inserted_user', array('nxt_ID' => $user_login_id, 'FB_ID' => $fb_uid, 'facebook' => $facebook, 'nxt_UserData' => $user_data));
}
//Tag the user with our meta so we can recognize them next time, without resorting to email hashes
update_user_meta($user_login_id, $jfb_uid_meta_name, $fb_uid);
$jfb_log .= "nxt: Updated usermeta ({$jfb_uid_meta_name})\n";
//Also store the user's facebook avatar(s), in case the user wants to use them later
if ($fbuser['pic_square']) {
    update_user_meta($user_login_id, 'facebook_avatar_thumb', $fbuser['pic_square']);
    update_user_meta($user_login_id, 'facebook_avatar_full', $fbuser['pic_big']);
    $jfb_log .= "nxt: Updated avatars (" . $fbuser['pic_square'] . ")\n";
예제 #3
0
<?php

//kobler til database
require '../../koble_til_database.php';
session_start();
$error = array('no_books' => 'Ingen b&oslash;ker er registrert.');
$get_books = "SELECT * FROM lib_Book";
$get_books_qry = $conn->query($get_books);
$res = array('error' => "");
if ($get_books_qry->num_rows > 0) {
    while ($book = $get_books_qry->fetch_assoc()) {
        //Find RFID
        $_rfid = "";
        $get_rfid = "SELECT RFID FROM lib_RFID WHERE bookID = '" . $book['bookID'] . "'";
        $get_rfid_qry = $conn->query($get_rfid);
        if ($get_rfid_qry->num_rows > 0) {
            if ($rfid = $get_rfid_qry->fetch_assoc()) {
                $_rfid = $rfid['RFID'];
            }
        }
        //Store results
        $res['books'][] = array('id' => $book['bookID'], 'RFID' => $_rfid, 'ISBN10' => $book['ISBN10'], 'ISBN13' => $book['ISBN13'], 'title' => $book['title'], 'author' => $book['author'], 'type' => $book['type'], 'language' => $book['language']);
    }
    if ($res == array('error' => "")) {
        j_die($error['no_books']);
    }
    echo json_encode($res);
} else {
    j_die($error['no_books']);
}
} else {
    if ($userinfo = $test_uname_result->fetch_assoc()) {
        $userID = $userinfo['userID'];
    } else {
        j_die($error['failed_to_get_user']);
    }
}
//oppretter en standardbruker, uten ekstra kontaktinfo
$insert_user = "******" . $phone . "', '" . $email . "', '" . $comment . "')";
$insert_user_result = $conn->query($insert_user);
if ($insert_user_result === TRUE) {
} else {
    j_die($error['failed_to_save_contact']);
}
$get_contact = "SELECT contactID FROM lib_Contact WHERE phone = '" . $phone . "' AND email = '" . $email . "' ORDER BY contactID DESC LIMIT 1";
$get_contact_qry = $conn->query($get_contact);
if ($get_contact_qry->num_rows > 0) {
    if ($contact = $get_contact_qry->fetch_assoc()) {
        $insert_contact = "INSERT INTO lib_User_Contact (contactID, userID) VALUES ('" . $contact['contactID'] . "', '" . $userID . "')";
        $insert_contact_qry = $conn->query($insert_contact_qry);
        if ($insert_contact_qry === TRUE) {
            j_die("");
        } else {
            j_die($error['failed_to_save_contact_info']);
        }
    } else {
        j_die($error['failed_to_get_contact']);
    }
} else {
    j_die($error['failed_to_get_contact']);
}
예제 #5
0
}
$get_user = "******" . $user_id . "'";
$get_user_qry = $conn->query($get_user);
if ($get_user_qry->num_rows > 0) {
    if ($user = $get_user_qry->fetch_assoc()) {
        //User is found in DB and info is passed on to result array
        $res = array('error' => '', 'userID' => $user['userID'], 'username' => $user['username'], 'firstname' => $user['firstname'], 'lastname' => $user['lastname'], 'birth' => $user['birth'], 'sex' => $user['sex'], 'school' => $user['school'], 'address' => $user['address'], 'registered' => $user['registered'], 'approved_date' => $user['approved_date']);
        //To avoid returning null variables
        if ($res['approved_date'] == null) {
            $res['approved_date'] = "";
        }
    } else {
        j_die($error['nonexistant_user']);
    }
} else {
    j_die($error['nonexistant_user']);
}
//Get the RFID
$res['rfid'] = '';
$get_rfid = "SELECT RFID FROM lib_RFID WHERE userID = '" . $user_id . "'";
$get_rfid_qry = $conn->query($get_rfid);
if ($get_rfid_qry->num_rows > 0) {
    if ($rfid = $get_rfid_qry->fetch_assoc()) {
        $res['rfid'] = $rfid['RFID'];
    }
}
//Get the total times, and time, the user has been borrowing books
$get_books = "SELECT TIMESTAMPDIFF(SECOND,outDate,inDate) AS timediff, outDate FROM lib_User_Book WHERE userID='" . $res['userID'] . "'";
$get_books_qry = $conn->query($get_books);
$res['total_times_borrowed'] = 0;
$total_time = 0;
$get_books = "SELECT TIMESTAMPDIFF(SECOND,outDate,inDate) AS timediff, outDate FROM lib_User_Book";
$get_books_qry = $conn->query($get_books);
$xx = 0;
$total_time = 0;
if ($get_books_qry->num_rows > 0) {
    while ($book = $get_books_qry->fetch_assoc()) {
        $xx++;
        if ($book['timediff'] == null) {
            $total_time += time() - strtotime($book['outDate']);
        } else {
            $total_time += $book['timediff'];
        }
    }
} else {
    //echo "No books borrowed";
    j_die($error['no_lended_books']);
}
$res["total_time_lended"] = convertSecondsToReadable($total_time);
$res["total_times_lended"] = $xx;
echo json_encode($res);
function convertSecondsToReadable($seconds)
{
    //Find difference in time in a readable format
    $dtF = new DateTime("@0");
    $dtT = new DateTime("@{$seconds}");
    $readable["months"] = (int) $dtF->diff($dtT)->format('%m');
    $readable["days"] = (int) $dtF->diff($dtT)->format('%a');
    $readable["hours"] = (int) $dtF->diff($dtT)->format('%h');
    $readable["minutes"] = (int) $dtF->diff($dtT)->format('%i');
    $readable["seconds"] = (int) $dtF->diff($dtT)->format('%s');
    $result = "";
예제 #7
0
    } else {
        //Book shall be lended
        //Check if user has been set
        if ($user === -1) {
            j_die($error['no_user_rfid']);
        }
        if ($res['type'] !== "deliver") {
            $res['type'] = 'lend';
            require ROOT . 'admin/info.class.php';
            $info = new Info("books", $books[$i]['bookID']);
            $result = $info->getInfo();
            $result['RFID'] = $books[$i]['rfid'];
            $result['shelfID'] = $books[$i]['shelfID'];
            $lend[] = array('user' => $user, 'date' => $date, 'book' => $result);
        } else {
            j_die($error['only_one_action_allowed']);
        }
    }
}
//Lend shiet
for ($i = 0; $i < count($lend); $i++) {
    $insert_user_book = "INSERT INTO lib_User_Book (userID, outDate, bookRFID, deliver_deadline) VALUES \n        ('" . $lend[$i]['user'] . "', '" . $lend[$i]['date'] . "', '" . $lend[$i]['book']['RFID'] . "', '" . $deliver_deadline . "')";
    $insert_user_book_qry = $conn->query($insert_user_book);
    if ($insert_user_book_qry === TRUE) {
        //Success
        $res['status'][] = array('book_info' => get_book_info($lend[$i]['book'], $deliver_deadline), 'error' => $error['lend_success']);
    } else {
        //Failed lend book
        $res['status'][] = array('book_info' => get_book_info($lend[$i]['book'], $deliver_deadline), 'error' => $error['failed_to_lend_book']);
    }
}
예제 #8
0
function jfb_process_login()
{
    //If this pageload isn't supposed to be handing a login, just stop here.
    global $jfb_nonce_name;
    if (!isset($_POST[$jfb_nonce_name])) {
        return;
    }
    //Start logging
    global $jfb_log, $jfb_version, $opt_jfb_app_id, $jfb_homepage;
    jfb_debug_checkpoint('start');
    $browser = jfb_get_browser();
    $jfb_log = "Starting login process (IP: " . $_SERVER['REMOTE_ADDR'] . ", User: "******", App: " . get_option($opt_jfb_app_id) . ", Version: {$jfb_version}, Browser: " . $browser['shortname'] . " " . $browser['version'] . " for " . $browser['platform'] . ")\n";
    //Run one hook before ANYTHING happens.
    $jfb_log .= "WP: Running action wpfb_prelogin\n";
    do_action('wpfb_prelogin');
    //Check the nonce to make sure this was a valid login attempt (unless the user has disabled nonce checking)
    global $opt_jfb_disablenonce, $jfb_nonce_name;
    if (!get_option($opt_jfb_disablenonce)) {
        if (wp_verify_nonce($_REQUEST[$jfb_nonce_name], $jfb_nonce_name) != 1) {
            //If there's already a user logged in, tell the user and give them a link back to where they were.
            $currUser = wp_get_current_user();
            if ($currUser->ID) {
                $msg = "User \"{$currUser->user_login}\" has already logged in via another browser session.\n";
                $jfb_log .= $msg;
                j_mail("FB Double-Login: "******" -> " . get_bloginfo('name'));
                die($msg . "<br /><br /><a href=\"" . $_POST['redirectTo'] . "\">Continue</a>");
            }
            j_die("Nonce check failed, login aborted.\nThis usually due to your browser's privacy settings or a server-side caching plugin.  If you get this error on multiple browsers, please contact the site administrator.\n");
        }
        $jfb_log .= "WP: nonce check passed\n";
    } else {
        $jfb_log .= "WP: nonce check DISABLED\n";
    }
    //Get the redirect URL
    global $redirectTo;
    if (!isset($_POST['redirectTo']) || !$_POST['redirectTo']) {
        j_die("Error: Missing POST Data (redirect)");
    }
    $redirectTo = $_POST['redirectTo'];
    $jfb_log .= "WP: Found redirect URL ({$redirectTo})\n";
    //Get the Facebook access token
    if (!isset($_POST['access_token']) || !$_POST['access_token']) {
        j_die("Error: Missing POST Data (access_token).\n\nIf you're receiving this notice via e-mail as a site administrator, it's nearly always safe to ignore (these errors are due to spambots automatically hitting your site).  If you're seeing this as a real person attempting to login, please report it to the plugin author at " . $jfb_homepage . ".");
    }
    $access_token = $_POST['access_token'];
    $jfb_log .= "FB: Found access token (" . substr($access_token, 0, 30) . "...)\n";
    //Get the basic user info and make sure the access_token is valid
    $jfb_log .= "FB: Initiating Facebook connection...\n";
    $fbuser = jfb_api_get("https://graph.facebook.com/me?access_token={$access_token}");
    if (isset($fbuser['error'])) {
        j_die("Error: Failed to get the Facebook user session (" . $fbuser['error']['message'] . ")");
    }
    $fb_uid = $fbuser['id'];
    do_action('wpfb_session_established', array('FB_ID' => $fb_uid, 'access_token' => $access_token));
    $jfb_log .= "FB: Connected to session (uid {$fb_uid})\n";
    //Get some extra stuff (TODO: I should combine these into one query with the above, for better efficiency)
    $fbuser['profile_url'] = $fbuser['link'];
    $pic = jfb_api_get("https://graph.facebook.com/fql?q=" . urlencode("SELECT pic_square,pic_big FROM user WHERE uid={$fb_uid}") . "&access_token={$access_token}");
    $fbuser['pic_square'] = $pic['data'][0]['pic_square'];
    $fbuser['pic_big'] = $pic['data'][0]['pic_big'];
    $jfb_log .= "FB: Got user info (" . $fbuser['name'] . ")\n";
    //See if we were given permission to access the user's email
    //This isn't required, and will only matter if it's a new user without an existing WP account
    //(since we'll auto-register an account for them, using the contact_email we get from Facebook - if we can...)
    $userRevealedEmail = false;
    if (strlen($fbuser['email']) != 0 && strpos($fbuser['email'], 'proxymail.facebook.com') === FALSE) {
        $jfb_log .= "FB: Email privilege granted (" . $fbuser['email'] . ")\n";
        $userRevealedEmail = true;
    } else {
        if (strlen($fbuser['email']) != 0) {
            $jfb_log .= "FB: Email privilege granted, but only for an anonymous proxy address (" . $fbuser['email'] . ")\n";
        } else {
            global $jfb_default_email;
            $jfb_log .= "FB: Email priviledge denied.\n";
            $fbuser['email'] = "FB_" . $fb_uid . $jfb_default_email;
        }
    }
    //Run a hook so users can`examine this Facebook user *before* letting them login.  You might use this
    //to limit logins based on friendship status - if someone isn't your friend, you could redirect them
    //to an error page (and terminate this script).
    $jfb_log .= "WP: Running action wpfb_connect\n";
    do_action('wpfb_connect', array('FB_ID' => $fb_uid, 'access_token' => $access_token));
    //Examine all existing WP users to see if any of them match this Facebook user.
    //The base query for getting the users comes from get_users_from_blog(), to which I add a subquery
    //that limits results only to users who also have the appropriate facebook usermeta.
    global $wp_users, $jfb_uid_meta_name;
    if (!isset($wp_users)) {
        global $wpdb, $blog_id;
        if (empty($id)) {
            $id = (int) $blog_id;
        }
        $blog_prefix = $wpdb->get_blog_prefix($id);
        $sql = "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value " . "FROM {$wpdb->users}, {$wpdb->usermeta} " . "WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' " . "AND {$wpdb->users}.ID IN (SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = '{$jfb_uid_meta_name}' AND meta_value = '{$fb_uid}')";
        $wp_users = $wpdb->get_results($sql);
    }
    //Although $wp_users should only contain the one matching user (or be empty), this "loop" method of searching
    //for matching usermeta is retained for backwards compatibility with old 3rd party hooks which may've relied on it.
    //Originally, $wp_users contained the full list of users (not just those with matching usermeta).
    $jfb_log .= "WP: Searching " . count($wp_users) . " existing candidates by meta...\n";
    $user_login_id = false;
    foreach ($wp_users as $wp_user) {
        $meta_uid = get_user_meta($wp_user->ID, $jfb_uid_meta_name, true);
        if ($meta_uid && $meta_uid == $fb_uid) {
            $user_data = get_userdata($wp_user->ID);
            $user_login_id = $wp_user->ID;
            $user_login_name = $user_data->user_login;
            $jfb_log .= "WP: Found existing user by meta (" . $user_login_name . ")\n";
            break;
        }
    }
    //Next, try to lookup their email directly (via Wordpress).  Obviously this will only work if they've revealed
    //their "real" address (vs denying access, or changing it to a "proxy" in the popup)
    if (!$user_login_id && $userRevealedEmail) {
        $jfb_log .= "WP: Searching for user by email address...\n";
        if ($wp_user = get_user_by('email', $fbuser['email'])) {
            $user_login_id = $wp_user->ID;
            $user_data = get_userdata($wp_user->ID);
            $user_login_name = $user_data->user_login;
            $jfb_log .= "WP: Found existing user (" . $user_login_name . ") by email (" . $fbuser['email'] . ")\n";
        }
    }
    //If we found an existing user, check if they'd previously denied access to their email but have now allowed it.
    //If so, we'll want to update their WP account with their *real* email.
    global $jfb_default_email;
    if ($user_login_id) {
        //Check 1: It was previously denied, but is now allowed
        $updateEmail = false;
        if (strpos($user_data->user_email, $jfb_default_email) !== FALSE && strpos($fbuser['email'], $jfb_default_email) === FALSE) {
            $jfb_log .= "WP: Previously DENIED email has now been allowed; updating to (" . $fbuser['email'] . ")\n";
            $updateEmail = true;
        }
        //Check 2: It was previously allowed, but only as an anonymous proxy.  They've now revealed their "true" email.
        if (strpos($user_data->user_email, "@proxymail.facebook.com") !== FALSE && strpos($fbuser['email'], "@proxymail.facebook.com") === FALSE) {
            $jfb_log .= "WP: Previously PROXIED email has now been allowed; updating to (" . $fbuser['email'] . ")\n";
            $updateEmail = true;
        }
        if ($updateEmail) {
            $user_upd = array();
            $user_upd['ID'] = $user_login_id;
            $user_upd['user_email'] = $fbuser['email'];
            wp_update_user($user_upd);
        }
        //Run a hook when an existing user logs in
        $jfb_log .= "WP: Running action wpfb_existing_user\n";
        do_action('wpfb_existing_user', array('WP_ID' => $user_login_id, 'FB_ID' => $fb_uid, 'WP_UserData' => $user_data, 'access_token' => $access_token));
    }
    //If we still don't have a user_login_id, the FB user who's logging in has never been to this blog.
    //We'll auto-register them a new account.  Note that if they haven't allowed email permissions, the
    //account we register will have a bogus email address (but that's OK, since we still know their Facebook ID)
    if (!$user_login_id) {
        $jfb_log .= "WP: No user found. Automatically registering (FB_" . $fb_uid . ")\n";
        $user_data = array();
        $user_data['user_login'] = "******" . $fb_uid;
        $user_data['user_pass'] = wp_generate_password();
        $user_data['user_nicename'] = sanitize_title($user_data['user_login']);
        $user_data['first_name'] = $fbuser['first_name'];
        $user_data['last_name'] = $fbuser['last_name'];
        $user_data['display_name'] = $fbuser['first_name'];
        $user_data['user_url'] = $fbuser["profile_url"];
        $user_data['user_email'] = $fbuser["email"];
        //Run a filter so the user can be modified to something different before registration
        //NOTE: If the user has selected "pretty names", this'll change FB_xxx to i.e. "John.Smith"
        $jfb_log .= "WP: Applying filters wpfb_insert_user/wpfb_inserting_user\n";
        $user_data = apply_filters('wpfb_insert_user', $user_data, $fbuser);
        $user_data = apply_filters('wpfb_inserting_user', $user_data, array('WP_ID' => $user_login_id, 'FB_ID' => $fb_uid, 'FB_UserData' => $fbuser, 'access_token' => $access_token));
        //Insert a new user to our database and make sure it worked
        $user_login_id = wp_insert_user($user_data);
        if (is_wp_error($user_login_id)) {
            j_die("Error: wp_insert_user failed!<br/><br/>" . "If you get this error while running a Wordpress MultiSite installation, it means you'll need to purchase the <a href=\"{$jfb_homepage}#premium\">premium version</a> of this plugin to enable full MultiSite support.<br/><br/>" . "If you're <u><i>not</i></u> using MultiSite, please report this bug to the plugin author on the support page <a href=\"{$jfb_homepage}#feedback\">here</a>.<br /><br />" . "Error message: " . (method_exists($user_login_id, 'get_error_message') ? $user_login_id->get_error_message() : "Undefined") . "<br />" . "WP_ALLOW_MULTISITE: " . (defined('WP_ALLOW_MULTISITE') ? constant('WP_ALLOW_MULTISITE') : "Undefined") . "<br />" . "is_multisite: " . (function_exists('is_multisite') ? is_multisite() : "Undefined"));
        }
        //Success! Notify the site admin.
        $user_login_name = $user_data['user_login'];
        wp_new_user_notification($user_login_id);
        //Run an action so i.e. usermeta can be added to a user after registration
        $jfb_log .= "WP: Running action wpfb_inserted_user\n";
        do_action('wpfb_inserted_user', array('WP_ID' => $user_login_id, 'FB_ID' => $fb_uid, 'WP_UserData' => $user_data, 'access_token' => $access_token));
    }
    //Tag the user with our meta so we can recognize them next time, without resorting to email hashes
    global $jfb_uid_meta_name;
    update_user_meta($user_login_id, $jfb_uid_meta_name, $fb_uid);
    $jfb_log .= "WP: Updated usermeta ({$jfb_uid_meta_name})\n";
    //Also store the user's facebook avatar(s), in case the user wants to use them later
    if ($fbuser['pic_square']) {
        if (isset($fbuser['pic_square']['data']['url'])) {
            $avatarThumb = $fbuser['pic_square']['data']['url'];
        } else {
            $avatarThumb = $fbuser['pic_square'];
        }
        if (isset($fbuser['pic_big']['data']['url'])) {
            $avatarFull = $fbuser['pic_big']['data']['url'];
        } else {
            $avatarFull = $fbuser['pic_big'];
        }
        update_user_meta($user_login_id, 'facebook_avatar_full', $avatarFull);
        update_user_meta($user_login_id, 'facebook_avatar_thumb', $avatarThumb);
        $jfb_log .= "WP: Updated small avatar ({$avatarThumb})\n";
        $jfb_log .= "WP: Updated large avatar ({$avatarFull})\n";
    } else {
        update_user_meta($user_login_id, 'facebook_avatar_thumb', '');
        update_user_meta($user_login_id, 'facebook_avatar_full', '');
        $jfb_log .= "FB: User does not have a profile picture; clearing cached avatar (if present).\n";
    }
    //Log them in
    $rememberme = apply_filters('wpfb_rememberme', isset($_POST['rememberme']) && $_POST['rememberme']);
    wp_set_auth_cookie($user_login_id, $rememberme);
    //Run a custom action.  You can use this to modify a logging-in user however you like,
    //i.e. add them to a "Recent FB Visitors" log, assign a role if they're friends with you on Facebook, etc.
    $jfb_log .= "WP: Running action wpfb_login\n";
    do_action('wpfb_login', array('WP_ID' => $user_login_id, 'FB_ID' => $fb_uid, 'access_token' => $access_token));
    do_action('wp_login', $user_login_name, get_userdata($user_login_id));
    //Email logs if requested
    $jfb_log .= "Login complete (rememberme=" . ($rememberme ? "yes" : "no") . ")\n";
    $jfb_log .= "   WP User : {$user_login_name} (" . admin_url("user-edit.php?user_id={$user_login_id}") . ")\n";
    $jfb_log .= "   FB User : "******" (" . $fbuser["profile_url"] . ")\n";
    $jfb_log .= "   Redirect: " . $redirectTo . "\n";
    j_mail("FB Login: "******" -> " . get_bloginfo('name'));
    //Redirect the user back to where they were
    global $opt_jfb_delay_redir;
    $delay_redirect = get_option($opt_jfb_delay_redir);
    if (!isset($delay_redirect) || !$delay_redirect) {
        header("Location: " . $redirectTo);
        exit;
    }
    ?>
    <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <title>Logging In...</title>
        </head>
        <body>
            <?php 
    $jfb_log .= "\n---REQUEST:---\n" . print_r($_REQUEST, true);
    ?>
 
            <?php 
    echo "<pre>" . $jfb_log . "</pre>";
    ?>
            <?php 
    echo '<a href="' . $redirectTo . '">Continue</a>';
    ?>
        </body>
    </html>
    <?php 
}
예제 #9
0
<?php

require '../../koble_til_database.php';
session_start();
$error = array('unknown_rfid' => 'Den skannede enheten er ikke registrert.', 'wrong_pin' => 'Feil PIN-kode.');
$post_vars = array('obligatory' => array('rfid'));
//Array that contains all the post information
$vars = $post->verify($post_vars);
require 'login.class.php';
$login = new Login();
$session = $login->create_session($vars['rfid']);
if ($session !== false) {
    die(json_encode(array('error' => '', 'sessionID' => $session)));
} else {
    //Failed
}
//That the code reaches this point will only occur if the queries have failed
j_die($error['unknown_rfid']);
예제 #10
0
 * Finn id'en til contact og user og link dem sammen
*/
$get_userid = "SELECT userID FROM lib_User WHERE username = '******'";
$get_userid_qry = $conn->query($get_userid);
if ($get_userid_qry->num_rows > 0) {
    if ($userinf = $get_userid_qry->fetch_assoc()) {
        $user_id = $userinf["userID"];
    } else {
        j_die($error['failed_to_access_userid']);
    }
} else {
    j_die($error['failed_to_access_userid']);
}
$get_contactid = "SELECT contactID FROM lib_Contact WHERE phone = '" . $phone . "' AND email = '" . $email . "' ORDER BY contactID DESC";
$get_contactid_qry = $conn->query($get_contactid);
if ($get_contactid_qry->num_rows > 0) {
    if ($contactinf = $get_contactid_qry->fetch_assoc()) {
        $contact_id = $contactinf["contactID"];
    } else {
        j_die($error['failed_to_access_contactid']);
    }
} else {
    j_die($error['failed_to_access_contactid']);
}
$insert_link = "INSERT INTO lib_User_Contact (contactID, userID) VALUES ('" . $contact_id . "', '" . $user_id . "')";
$insert_link_res = $conn->query($insert_link);
if ($insert_link_res === TRUE) {
    j_die("");
} else {
    j_die($error['failed_to_link_contact']);
}
예제 #11
0
            for ($i = 0; $i < count($feedback['stars']); $i++) {
                $total_stars += intval($feedback['stars'][$i]['value']);
            }
            $average_stars = $total_stars / count($feedback['stars']);
        }
        $feedback['average_stars'] = $average_stars;
        //Print book info
        $res['book'] = array('ISBN10' => $book['ISBN10'], 'ISBN13' => $book['ISBN13'], 'total_lend_time' => convertSecondsToReadable($total_lended_time), 'total_lend_times' => count($borrowers), 'borrowers' => $borrowers_v2, 'feedback' => $feedback);
        echo json_encode($res);
    } else {
        //Query failed (nonexistant book or SQL error)
        j_die($error['nonexistant_book']);
    }
} else {
    //Query failed (nonexistant book or SQL error)
    j_die($error['nonexistant_book']);
}
function convertSecondsToReadable($seconds)
{
    //Find difference in time in a readable format
    $dtF = new DateTime("@0");
    $dtT = new DateTime("@{$seconds}");
    $readable["months"] = (int) $dtF->diff($dtT)->format('%m');
    $readable["days"] = (int) $dtF->diff($dtT)->format('%a');
    $readable["hours"] = (int) $dtF->diff($dtT)->format('%h');
    $readable["minutes"] = (int) $dtF->diff($dtT)->format('%i');
    $readable["seconds"] = (int) $dtF->diff($dtT)->format('%s');
    $result = "";
    $prev_value = false;
    return $readable;
}
예제 #12
0
                }
            }
        }
    }
} else {
    j_die($error['missing_rfid']);
}
//Verify the type of value
if ($type == "comment") {
    if ($value == "") {
        j_die($error['empty_comment']);
    }
} else {
    if (!is_numeric($value)) {
        j_die($error['not_int']);
    } else {
        if (intval($value) > 6 || intval($value) < 0) {
            j_die($error['unaccepted_int']);
        }
    }
}
//Save the feedback
$date = (new DateTime())->format('Y-m-d H:i:s');
$save_feedback = "INSERT INTO lib_Feedback (user_rfid, book_rfid, type, value, timestamp) VALUES ('" . $user . "', '" . $book . "', '" . $type . "', '" . $value . "', '" . $date . "')";
$save_feedback_qry = $conn->query($save_feedback);
if ($save_feedback_qry === TRUE) {
    //Success
    j_die("");
} else {
    j_die($error['failed_save']);
}
예제 #13
0
            $shelf = $_res[1];
        } else {
            //Two user RFID's are selected
            j_die($error['multiple_shelf_rfid']);
        }
    } else {
        if ($_res[0] == 'book') {
            $book_ids[] = $rfid_arr[$i];
        }
    }
}
if (isset($vars['shelf_id'])) {
    $shelf = $vars['shelf_id'];
}
if ($shelf == -1) {
    j_die($error['no_shelf']);
}
foreach ($book_ids as $book_rfid) {
    /*$get_book = "SELECT * FROM lib_Book WHERE bookID = '".$book_id."'";
      $get_book_qry = $conn->query($get_book);
      if($get_book_qry->num_rows > 0){
          if($book = $get_book_qry->fetch_assoc()){
              
          }
      }*/
    $update_book = "UPDATE lib_RFID SET `_shelfID` = '" . $shelf . "' WHERE RFID = '" . $book_rfid . "'";
    $update_book_qry = $conn->query($update_book);
    if ($update_book_qry === TRUE) {
        //Success
    } else {
        //Failed