2017-04-09 20 views
3

バニラフォーラム2.3バニラフォーラムSSOのPHPは

私はこれを数回以上されていると私は私が見つけることができるほぼすべてのドキュメントを見てきましたが、私は立ち往生午前フォーラムにログインしていません。私はバニラの最新バージョンをダウンロードしていると私はjsconnectプラグインの最新バージョンをダウンロードした

..

私はすべての設定は、管理エリア内jsconnectプラグインの設定で設定した

jsConnect設定

ログインURL http://localhost/site/login.php

申し込みURL http://localhost/site/register.php

http://localhost/site/forums/

認証URL http://localhost/site/includes/auth.php

ので、私リットルに位置してログアウトURLが http://localhost/site/logout.php

フォーラム私のサイトすべてが、私はそれが私がログインしていないよと言うフォーラムをクリックしてください素晴らしいです。

マイログインページ機能

function login_user($email, $password){ 

    $active = 1; 

    $db = dbconnect(); 
    $stmt = $db->prepare('SELECT * FROM users WHERE email = ? AND active= ?'); 
    $stmt->bind_param('si', $email, $active); 
    $stmt->execute(); 
    $result = $stmt->get_result(); 

    if ($result->num_rows == 1) { 
     $row = $result->fetch_array(); 

     $id = $row['id']; 
     $email = $row['email']; 
     $username = $row['username']; 
     $db_password = $row['password']; 

     isset($_POST['remember']) ? $remember = $_POST['remember'] : $remember = ""; 

     if (password_verify($password, $db_password)) { 

      $_SESSION['id'] = $id; 
      $_SESSION['email'] = $email; 
      $_SESSION['username'] = $username; 

      $fingerprint = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']); 
      $_SESSION['last_active'] = time(); 
      $_SESSION['fingerprint'] = $fingerprint; 

      if($remember === "yes"){ 
      rememberMe($id); 
      } 

      return true; 
     } else { 
      return false; 
     } 
     return true; 
    } else { 
     return false; 
    } 
} 

マイauthenticate.php

にogin
<?php 

include_once '../db/db.php'; 
include_once '../db/functions.php'; 
require_once '../vanilla/plugins/jsconnect/functions.jsconnect.php'; 



// 1. Get your client ID and secret here. These must match those in your jsConnect settings. 
$clientID = "xxxxx"; 
$secret = "xxxxxxxxxx"; 



// 2. Grab the current user from your session management system or database here. 
$signedIn = true; // this is just a placeholder 

if($_SESSION['id']) 
    $signedIn = true; 


// 3. Fill in the user information in a way that Vanilla can understand. 
$user = array(); 


if ($signedIn) { 
    // CHANGE THESE FOUR LINES. 

    $user['uniqueid'] = $_SESSION['id']; 
    $user['name'] = $_SESSION['username']; 
    $user['email'] = $_SESSION['email']; 

} 

// 4. Generate the jsConnect string. 

// This should be true unless you are testing. 
// You can also use a hash name like md5, sha1 etc which must be the name as the connection settings in Vanilla. 
$secure = true; 

WriteJsConnect($user, $_GET, $clientID, $secret, $secure); 

exit(); 

?> 
+0

を試してみてください を使用する必要があります。このページでセッションを開始しないで表示され、ここでhttps://github.com/vanilla/jsConnectPHPです – Case

答えて

3

私がすべてがバニラJSがSSO PHPを接続する必要持っているあなたは、あなたが以下の

<?php 
session_start(); 

include_once '../db/db.php'; 
include_once '../db/functions.php'; 
require_once '../vanilla/plugins/jsconnect/functions.jsconnect.php';