Example #1
0
function &db_get_instance($name = 'main', $readonly = false)
{
    global $_OPENPNE_DB_LIST;
    if (empty($_OPENPNE_DB_LIST[$name])) {
        if (!($dsn = db_get_dsn($name))) {
            if ($name == 'main') {
                return false;
            } else {
                $_OPENPNE_DB_LIST[$name] =& db_get_instance();
            }
        } else {
            $_OPENPNE_DB_LIST[$name] =& new OpenPNE_DB($dsn, $readonly);
        }
    }
    return $_OPENPNE_DB_LIST[$name];
}
Example #2
0
 function execute($requests)
 {
     $config['storage'] = 'DB';
     $config['options'] = array('dsn' => db_get_dsn(), 'table' => 'c_admin_user', 'usernamecol' => 'username', 'passwordcol' => 'password', 'cryptType' => 'md5');
     $auth = new OpenPNE_Auth($config);
     $auth->setExpire($GLOBALS['OpenPNE']['admin']['session_lifetime']);
     $auth->setIdle($GLOBALS['OpenPNE']['admin']['session_idletime']);
     $this->_auth =& $auth;
     // 現在のセッションを削除
     $auth->logout();
     if (!$auth->login($requests['is_save'])) {
         $this->_fail_login();
     }
     if (OPENPNE_ONE_SESSION_PER_USER) {
         $uid = db_admin_c_admin_user_id4username($auth->getUsername());
         db_admin_update_c_admin_user_insert_sess_id($uid, session_id());
     }
     admin_client_redirect('top');
 }
Example #3
0
function get_auth_config($is_ktai = false)
{
    if (OPENPNE_AUTH_MODE == 'slavepne') {
        $config = $GLOBALS['_OPENPNE_AUTH_CONFIG'];
    } elseif (OPENPNE_AUTH_MODE == 'pneid') {
        $config['storage'] = 'DB';
        $config['is_lowercase_username'] = true;
        $config['options'] = array('dsn' => db_get_dsn(), 'auto_quote' => false, 'table' => 'c_member_secure AS cms INNER JOIN c_username AS cu USING (c_member_id)', 'db_fields' => 'cms.hashed_password AS hashed_password, cu.username AS username', 'usernamecol' => 'username', 'passwordcol' => 'hashed_password', 'cryptType' => 'md5');
    } else {
        $config['storage'] = 'DB';
        $config['is_encrypt_username'] = true;
        if ($is_ktai) {
            $config['options'] = array('dsn' => db_get_dsn(), 'table' => 'c_member_secure', 'usernamecol' => 'ktai_address', 'passwordcol' => 'hashed_password', 'cryptType' => 'md5');
        } else {
            $config['options'] = array('dsn' => db_get_dsn(), 'table' => 'c_member_secure', 'usernamecol' => 'pc_address', 'passwordcol' => 'hashed_password', 'cryptType' => 'md5');
        }
    }
    $config['is_ktai'] = $is_ktai;
    if ($is_ktai) {
        $config['is_check_user_agent'] = OPENPNE_SESSION_CHECK_KTAI_USER_AGENT;
    } else {
        $config['is_check_user_agent'] = OPENPNE_SESSION_CHECK_PC_USER_AGENT;
    }
    return $config;
}
Example #4
0
 /**
  * セッションハンドラを設定する
  *
  * @static
  */
 function set_session_save_handler()
 {
     static $sess_storage;
     if (is_null($sess_storage)) {
         switch (SESSION_STORAGE) {
             case 1:
                 include_once 'OpenPNE/DBSession.php';
                 $sess_storage = new OpenPNE_DBSession(db_get_dsn('session'));
                 break;
             case 2:
                 include_once 'OpenPNE/MemcacheSession.php';
                 $sess_storage = new OpenPNE_MemcacheSession($GLOBALS['_OPENPNE_MEMCACHE_LIST']['session']['dsn']);
                 break;
             default:
                 return;
         }
     }
     if (!is_null($sess_storage)) {
         session_set_save_handler(array(&$sess_storage, 'open'), array(&$sess_storage, 'close'), array(&$sess_storage, 'read'), array(&$sess_storage, 'write'), array(&$sess_storage, 'destroy'), array(&$sess_storage, 'gc'));
     }
 }