'2011/01'에 해당되는 글 1건

  1. 2011.01.26 AjaxPlorer3.2 설치형 웹하드와 사이트 계정 연동 5
2011. 1. 26. 11:13

1. conf.php파일 수정
파일경로: ajaxplorer/server/conf/conf.php
수정내용: AUTH_DRIVER(116라인)의 내용을 아래 내용으로 대체한다.
==============================================================================
"AUTH_DRIVER" => array(
  "NAME"  => "remote",
  "OPTIONS" => array(
   "SLAVE_MODE"   => true,
   "USERS_FILEPATH"  => "AJXP_INSTALL_PATH/server/users/users.ser",
   "LOGIN_URL"    => "/your_cms/login.php",            //로그인이 안되어 있을때 이동할 페이지
   "LOGOUT_URL"   => "/your_cms/homepage.php",  //로그아웃시 이동할 페이지
   "SECRET"    => "myprivatesecret",
   "TRANSMIT_CLEAR_PASS" => false)
 ),
==============================================================================


2. 실제 사이트 계정과 연동
   1) 로그인 연동
      로그인후 ajaxplorer경로로 이동시키기 전에 아래 페이지를 거져 이동시키도록 수정한다.
==============================================================================
<?php
// Here the PHP code for handling the form and the HTML code
// for displaying it are in the same file "login.php"
// but it's not necessary!
//POST방식으로 아이디와 비밀번호를 넘겨받는다
if(isSet($_POST["login"]) && isSEt($_POST["password"])){

// Necessary to make "connection" with the glueCode
define("AJXP_EXEC", true);

//ajaxplorer의 glueCode.php파일이 있는 절대 경로
$glueCode = "absolute/path/to/ajxp/plugins/auth.remote/glueCode.php";

//conf.php 파일의 SECRET 변수값과 동일해야 된다.
$secret = "myprivatesecret";  

// Initialize the "parameters holder"
global $AJXP_GLUE_GLOBALS;
$AJXP_GLUE_GLOBALS = array();
$AJXP_GLUE_GLOBALS["secret"] = $secret;

//login, logout, addUser, delUser, updateUser 옵션을 사용할수 있다.
$AJXP_GLUE_GLOBALS["plugInAction"] = "login";

//true로 변경시 ajaxplorer에 계정이 없을경우 자동으로 계정생성해준다.
$AJXP_GLUE_GLOBALS["autoCreate"] = false; 

// NOTE THE md5() call on the password field.
$AJXP_GLUE_GLOBALS["login"] = array("name" => $_POST["login"], "password" => md5($_POST["password"]));

// NOW call glueCode!
   include($glueCode);
}
?>
==============================================================================

   2) 로그아웃 연동
==============================================================================
<?php
// Necessary to make "connection" with the glueCode
define("AJXP_EXEC", true);

//ajaxplorer의 glueCode.php파일이 있는 절대 경로
$glueCode = "absolute/path/to/ajxp/plugins/auth.remote/glueCode.php";

//conf.php 파일의 SECRET 변수값과 동일해야 된다.
$secret = "myprivatesecret";  

// Initialize the "parameters holder"
global $AJXP_GLUE_GLOBALS;
$AJXP_GLUE_GLOBALS = array();
$AJXP_GLUE_GLOBALS["secret"] = $secret;

//login, logout, addUser, delUser, updateUser 옵션을 사용할수 있다.
$AJXP_GLUE_GLOBALS["plugInAction"] = "logout";   

// NOW call glueCode!
include($glueCode);
?>
==============================================================================

그외에 웹하드에 사용자추가(addUser), 사용자삭제(delUser), 비밀번호수정(updateUser)등을 연동할수 있다.

테스트 사이트 주소는 다음과 같습니다.(계정은 제가 임의로 입력해 놓았습니다)
http://www.story4u.pe.kr/test.php

ps.테스트 사이트에 적용된 소스를 첨부파일로 올려놓겠습니다.
test.php(로그인 페이지)
test2.php(로그아웃 페이지)
conf.php(ajaxplorer conf파일, 기존파일에 덮어쓰기 하셔도 됩니다)

Posted by 굿데이