1

论坛成员为我的网站创建了一个身份验证系统,允许用户使用 facebook api (facebook sdk) 在我的网站上登录或注册

由于未知原因(我一定是在某个地方搞砸了)系统停止工作,我无法连接。

你能帮我解决这个问题吗?

我正在使用 facebook-sdk php 类(https://github.com/facebook/facebook-php-sdk)(使用的文件上传到 pastebin,因为它们太长了)

facebook 连接窗口正在打开,发回的 url 似乎包含身份验证所需的信息(但没有创建 facebook 的 cookie(未在 chrome 控制台上显示))

所以我认为问题必须来自我使用 smarty 作为模板引擎的 config.php 文件,如果这会影响任何东西。

我的网站 www.entendu.info

登录网址:www.entendu.info/login

非常感谢

<?php

require_once ($config[basedir] . '/include/facebook_api/facebook.php');

if ($config['enable_fc'] == "1") {

    $facebook = new Facebook( array('appId' => '**APPID***', 'secret' => '***SECRETID***', ));
    $user = $facebook -> getUser();

    if ($user) {
        try {
            // Proceed knowing you have a logged in user who's authenticated.
            $user_profile = $facebook -> api('/me');
        } catch (FacebookApiException $e) {
            error_log($e);
            $user = null;
        }
    }
    if (isset($_SESSION['fb_277467322296156_user_id'])) {

        $femail = $user_profile['email'];
        $fname = $user_profile['name'];
        $fname = htmlentities(strip_tags($fname), ENT_COMPAT, "UTF-8");
        $femail = htmlentities(strip_tags($femail), ENT_COMPAT, "UTF-8");
        $fsex = $user_profile['gender'];
        $fsex = htmlentities(strip_tags($fsex), ENT_COMPAT, "UTF-8");
        if ($fsex == "male") {
            $ag = "1";
        } else {
            $ag = "0";
        }

        $ffirstname = $user_profile['first_name'];
        $flastname = $user_profile['last_name'];

        $date = explode('/', $user_profile['birthday']);
        $fbirthday = $date[2] . "/" . $date[0] . "/" . $date[1];

        $fcity = $user_profile['hometown']['name'];

        $query = "SELECT USERID FROM members WHERE email='" . mysql_real_escape_string($femail) . "' limit 1";
        $executequery = $conn -> execute($query);
        $FUID = intval($executequery -> fields['USERID']);
        if ($FUID > 0) {
            $query = "SELECT USERID,email,username,verified,gender from members WHERE USERID='" . mysql_real_escape_string($FUID) . "' and status='1'";
            $result = $conn -> execute($query);
            if ($result -> recordcount() > 0) {
                $query = "update members set lastlogin='" . time() . "', lip='" . $_SERVER['REMOTE_ADDR'] . "' WHERE USERID='" . mysql_real_escape_string($FUID) . "'";
                $conn -> execute($query);

                $_SESSION['USERID'] = $result -> fields['USERID'];
                $_SESSION['EMAIL'] = $result -> fields['email'];
                $_SESSION['USERNAME'] = $result -> fields['username'];
                $_SESSION['VERIFIED'] = $result -> fields['verified'];
                $_SESSION['GENDER'] = $result -> fields['gender'];
                $_SESSION['FB'] = "1";

            }
        } else {
            $md5pass = md5(generateCode(5) . time());

            if ($fname != "" && $femail != "") {

                $query = "INSERT INTO members SET email='" . mysql_real_escape_string($femail) . "',birthday='" . mysql_real_escape_string($fbirthday) . "',city='" . mysql_real_escape_string($fcity) . "',username='" . mysql_real_escape_string($fname) . "',firstname='" . mysql_real_escape_string($ffirstname) . "',lastname='" . mysql_real_escape_string($flastname) . "', password='" . mysql_real_escape_string($md5pass) . "', addtime='" . time() . "', lastlogin='" . time() . "', ip='" . $_SERVER['REMOTE_ADDR'] . "', lip='" . $_SERVER['REMOTE_ADDR'] . "', verified='1', gender='" . $ag . "'";
                $result = $conn -> execute($query);
                $userid = mysql_insert_id();
                if ($userid != "" && is_numeric($userid) && $userid > 0) {

                    $query = "SELECT USERID,email,username,verified,gender from members WHERE USERID='" . mysql_real_escape_string($userid) . "'";
                    $result = $conn -> execute($query);

                    $_SESSION['USERID'] = $result -> fields['USERID'];
                    $_SESSION['EMAIL'] = $result -> fields['email'];
                    $_SESSION['USERNAME'] = $result -> fields['username'];
                    $_SESSION['VERIFIED'] = $result -> fields['verified'];
                    $_SESSION['SGENDER'] = $result -> fields['gender'];
                    $_SESSION['FB'] = "1";

                    $url = "http://graph.facebook.com/$user/picture?type=large";
                    $sourceFilePath = CurlHelper::downloadFile($url, array('followLocation' => true, 'maxRedirs' => 5, ));

                    $theimageinfo = getimagesize($sourceFilePath);
                    $thepp = $_SESSION['USERID'];

                    if ($theimageinfo[2] == 1) {
                        $thepp .= ".gif";
                    } elseif ($theimageinfo[2] == 2) {
                        $thepp .= ".jpg";
                    } elseif ($theimageinfo[2] == 3) {
                        $thepp .= ".png";
                    }

                    $myvideoimgnew = $config['membersprofilepicdir'] . "/" . $thepp;

                    $thumb = PhpThumbFactory::create($sourceFilePath);

                    //on save tel quel
                    $thumb -> save($myvideoimgnew);
                    //on redimensionne la photo
                    $thumb -> resize(100, 100);
                    // save dans le bon rep
                    $tothumbdir = $config['membersprofilepicdir'] . "/thumbs/" . $thepp;
                    $thumb -> save($tothumbdir);

                    if (file_exists($config['membersprofilepicdir'] . "/" . $thepp)) {
                        $query = "UPDATE members SET profilepicture='$thepp' WHERE USERID='" . mysql_real_escape_string($_SESSION['USERID']) . "'";
                        $conn -> execute($query);
                    } else {
                        $error = "$lang[135]";
                    }

                }
            }
        }
    } else {
        $facebook = new Facebook( array('appId' => '**APPID**', 'secret' => '**SECRETID**', ));
        $params = array(scope => 'email, user_birthday');

        $loginUrl = $facebook -> getLoginUrl($params);


        if ($_SESSION['language'] == "english") {

            $loginLien_right = "<a href='$loginUrl'><img id='fb_login_image' src='$config[imageurl]/fb_signup_en_right.png' alt='Login Facebook'/></a>";

            $loginLien = "<a href='$loginUrl'><img id='fb_login_image' src='$config[imageurl]/fb_signup_en.png' alt='Login Facebook'/></a>";
        } else {

            $loginLien_right = "<a href='$loginUrl'><img id='fb_login_image' src='$config[imageurl]/fb_signup_fr_right.png' alt='Login Facebook'/></a>";
            $loginLien = "<a href='$loginUrl'><img id='fb_login_image' src='$config[imageurl]/fb_signup_fr.png' alt='Login Facebook'/></a>";
        }


        STemplate::assign('loginFB', $loginLien);
        STemplate::assign('loginFBright', $loginLien_right);

    }
}




?>

因为我没有 10 个以上的声誉,所以我不能发布超过 2 个超链接,所以我将它们加入了 pastebin 链接

http://pastebin.com/02cm3DjZ

非常感谢

4

0 回答 0