getDB(), getRootDB()를 autoload 클래스로 변경

- 각각 DB::db(), RootDB::db()임.
This commit is contained in:
2018-03-25 00:07:37 +09:00
parent bb1a496835
commit 9e1aadf486
62 changed files with 258 additions and 269 deletions
@@ -1,6 +1,5 @@
<?php
namespace kakao;
require(__dir__.'/../vendor/autoload.php');
class KakaoKey{
const REST_KEY = '_tK_REST_API_KEY_';
+54
View File
@@ -0,0 +1,54 @@
<?php
namespace sammo;
class RootDB{
private static $uDB = null;
private static $host = '_tK_host_';
private static $user = '_tK_user_';
private static $password = '_tK_password_';
private static $dbName = '_tK_dbName_';
private static $port = _tK_port_;
private static $encoding = 'utf8';
private static $globalSalt = '_tK_globalSalt_';
private static $serverWebPath = '_tK_serverBasePath';
private function __construct(){
}
/**
* DB 객체 생성
*
* @return \MeekroDB
*/
public static function db(){
if(self::$uDB === null){
self::$uDB = new \MeekroDB(self::$host,self::$user,self::$password,self::$dbName,self::$port,self::$encoding);
self::$uDB->connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
}
return self::$uDB;
}
/**
* 비밀번호 해시용 전역 SALT 반환
* 비밀번호는 sha512(usersalt|sha512(globalsalt|password|globalsalt)|usersalt); 순임
*
* @return string
*/
public static function getGlobalSalt(){
return self::$globalSalt;
}
/**
* 서버 주소 반환. 서버의 경로가 하부 디렉토리인 경우에 하부 디렉토리까지 포함
*
* @return string
*/
public static function getServerBasepath(){
//FIXME: 더 좋은 위치가 있을 것.
return self::$globalSalt;
}
}
-46
View File
@@ -1,46 +0,0 @@
<?php
namespace sammo;
require(__dir__.'/../vendor/autoload.php');
/**
* 비밀번호 해시용 전역 SALT 반환
* 비밀번호는 sha512(usersalt|sha512(globalsalt|password|globalsalt)|usersalt); 순임
*
* @return string
*/
function getGlobalSalt(){
return '_tK_globalSalt_';
}
/**
* 서버 주소 반환. 서버의 경로가 하부 디렉토리인 경우에 하부 디렉토리까지 포함
*
* @return string
*/
function getServerBasepath(){
return '_tK_serverBasePath_';
}
/**
* DB 객체 생성
*
* @return \MeekroDB
*/
function getRootDB(){
$host = '_tK_host_';
$user = '_tK_user_';
$password = '_tK_password_';
$dbName = '_tK_dbName_';
$port = _tK_port_;
$encoding = 'utf8';
static $uDB = null;
if($uDB === null){
$uDB = new \MeekroDB($host,$user,$password,$dbName,$port,$encoding);
$uDB->connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
}
return $uDB;
}