File common.function.php - Prev/engine-pmc GitHub Wiki

์†Œ๊ฐœ

๊ฐ์ข… ์œ ์šฉํ•œ ํ•จ์ˆ˜๋“ค์„ ๋ชจ์•„๋‘” ํŒŒ์ผ์ž…๋‹ˆ๋‹ค. engine-pmc/lib/functions์— ์œ„์น˜ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

ํ•จ์ˆ˜

var_dump2(mixed $obj)

var_dump($obj) ํ•จ์ˆ˜๋ฅผ ๊ฐœ์กฐํ•œ ํ•จ์ˆ˜

<pre> ํƒœ๊ทธ๊ฐ€ ๋ถ™์–ด ์†Œ์Šค๋ณด๊ธฐ๋ฅผ ์•ˆํ•ด๋„ ๋“ค์—ฌ์“ฐ๊ธฐ์™€ ์ค„๋ฐ”๊ฟˆ์ด ์ž๋™์œผ๋กœ ํ‘œ์‹œ๋˜๋ฉฐ DEBUG_MODE์‹œ ์ฝ”๋“œ๊ฐ€ ํ•˜์ด๋ผ์ดํŒ…๋˜์–ด ํ‘œ์‹œ๋จ

===========================

getContent([string $moduleID=NULL, string $moduleAction=NULL, object $queryParam=NULL])

๋ชจ๋“ˆ์˜ ๋‚ด์šฉ์„ ๊ฐ€์ ธ์˜ด, ๋‹ค์ค‘ ๋ชจ๋“ˆ ์ด์šฉ์‹œ ์‚ฌ์šฉ

Context::getModuleContent ๋ฉ”์†Œ๋“œ์™€ ๊ฐ™์œผ๋ฉฐ $moduleID, $moduleAction ๋ฏธ์ง€์ •์‹œ ๊ธ€๋กœ๋ฒŒ ๋ชจ๋“ˆ์˜ ๋‚ด์šฉ์„ ๋ฐ˜ํ™˜ํ•จ

===========================

getMenuTag(int $level[, bool $noDeco=true])

menu์˜ ๋‚ด์šฉ์„ html

  • ๋กœ ๊ฐ€๊ณตํ•œ ๋‚ด์šฉ์„ ๋ฐ˜ํ™˜ํ•จ

    #####Parameter

    • $level ๊ฐ€์ ธ์˜ฌ ๋ฉ”๋‰ด์˜ level์„ ์ •์˜ํ•จ
    • $noDeco ๋Š”
    • ํƒœ๊ทธ ๋ฐ‘ ํƒœ๊ทธ์—์„œ class="no-deco" ๋ฅผ ์‚ฌ์šฉํ• ์ง€ ๋ง์ง€ ๊ฒฐ์ •

    ===========================

    getFilePathClear(string $path)

    C:\\APM_Setup\\pmc/lib/classes/Context.class.php ๋“ฑ์˜ ์ง€์ €๋ถ„ํ•œ URL์„ /lib/classes/Context.class.php ์ฒ˜๋Ÿผ ๊นจ๋—ํ•˜๊ฒŒ ์ •๋ฆฌํ•˜์—ฌ ์ถœ๋ ฅ

    #####Parameter

    • $path ์›๋ณธ ๊ฒฝ๋กœ

    ===========================

    getUpperPath(string $path)

    ์ƒ์œ„ ๋””๋ ‰ํ† ๋ฆฌ ํด๋”๋ฅผ ๋ฐ˜ํ™˜ํ•จ

    #####Examples

    1. getUpperPath('/modules/index/template/') => '/modules/index/'
    2. getUpperPath('/modules/file') => '/module/'

    #####Parameter

    • $path : ์›๋ณธ ๊ฒฝ๋กœ

    ===========================

    fillZero(string $str[, int $length=2])

    ๋ฌธ์ž์˜ ๊ธธ์ด๋งŒํผ ๋นˆ๊ณณ์— 0์„ ์ง‘์–ด๋„ฃ์Œ, ์‹œ๊ฐ„ํ‘œ์‹œ์‹œ ์ฃผ๋กœ ์‚ฌ์šฉ

    #####Parameter

    • $length 0์„ ์ฑ„์›Œ๋„ฃ์„ ๊ธธ์ด๋ฅผ ์ •์˜ํ•จ

    ===========================

    setCookie2(string $name, string $value, [int $expire=0, boolean $secure=false, boolean $httponly=false])

    ์ตœ์ƒ๋‹จ uri, ์„ธ์…˜์œผ๋กœ ์ฟ ํ‚ค๋ฅผ ์‹ฌ์Œ

    #####Parameter

    • $name ์ฟ ํ‚ค ์ด๋ฆ„
    • $value ์ฟ ํ‚ค์— ๋„ฃ์„ ๋‚ด์šฉ ์ดํ›„ ์ธ์ž๋“ค์€ setcookie ํ•จ์ˆ˜์™€ ๋™์ผํ•จ

    ===========================

    evalCheckbox(mixed $formData)

    form ๋ฐ์ดํ„ฐ ์ˆ˜์‹ ์‹œ checkbox ๋‚ด์šฉ ์ฒดํฌ

    ๊ฐ’์ด true ์ด๊ฑฐ๋‚˜ on ์ผ์‹œ true ๋ฐ˜ํ™˜

    #####Parameter

    • $formData ํŠน์ • form data (์ฃผ๋กœ CheckBox์˜ ๊ฐ’์„ ๋ฐ˜ํ™˜)

    ===========================

    getRelativeTime(string $time)

    ์ƒ๋Œ€์  ์‹œ๊ฐ„ ์ถœ๋ ฅ

    ex) 2013-06-23 11:32:12 -> 13๋ถ„ ์ „

    #####Parameter

    • $time timestamp ๊ฐ’

    ===========================

    getLocale([object $compareLocale=NULL])

    ํ˜„์žฌ ์„ค์ • ์–ธ์–ด ์ •๋ณด๋ฅผ ์ถœ๋ ฅ

    #####Parameter

    • $compareLocal ๊ฐ’์„ ์ง€์ •์‹œ ํ˜„์žฌ ์–ธ์–ด์ •๋ณด์™€ ๊ฐ™์€์ง€ ๋น„๊ตํ•œ ๊ฐ’์„ ๋ฐ˜ํ™˜

    ===========================

    fetchLocale(object $data)

    ์–ธ์–ด๋ฅผ ํŒŒ์‹ฑํ•จ (๋‹ค๊ตญ์–ด)

    #####Parameter

    • $data object, array, string(json), string(raw) ๋“ฑ์ด ์˜ฌ ์ˆ˜ ์žˆ์Œ

    #####Note

    • raw string ๊ฐ’์ด ์˜ฌ ์‹œ ๊ทธ๋Œ€๋กœ ์ถœ๋ ฅํ•จ

    • object: (object) array('en' => 'Freeboard', 'kr' => '์ž์œ ๊ฒŒ์‹œํŒ')

    • array: array('en' => 'Freeboard', 'kr' => '์ž์œ ๊ฒŒ์‹œํŒ')

    • string(json): {"en":"Freeboard", "kr":"์ž์œ ๊ฒŒ์‹œํŒ"}

    • string(raw): "์ž์œ ๊ฒŒ์‹œํŒ"

    ===========================

    readFileContent(string $filePath)

    ํŒŒ์ผ ๋‚ด์šฉ์„ ๋ชจ๋‘ ์ฝ์–ด์„œ ์ถœ๋ ฅํ•จ

    #####Parameter

    • $filePath ์ˆœ์ˆ˜ ํŒŒ์ผ ๊ฒฝ๋กœ

    ===========================

    json_encode2(mixed $data)

    json_encode์™€ ๋น„์Šท

    #####Note ์œ ๋‹ˆ์ฝ”๋“œ ๊ฐ’์„ \ucXXX ๋กœ ์น˜ํ™˜ํ•˜์ง€ ์•Š์œผ๋ฉฐ json_encode๊ฐ€ ๊ตฌํ˜„๋˜์ง€ ์•Š์€์„œ๋ฒ„์—์„œ๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Œ

    #####Parameter

    • $data encode ํ•  ๋ฐ์ดํ„ฐ

    ===========================

    escape(string $string)

    ์ฟผ๋ฆฌ ๋ฐ์ดํ„ฐ ์ด์Šค์ผ€์ดํ”„ ํ•จ์ˆ˜

    ######Note mysql_real_ecape_string๊ณผ ๋น„์Šทํ•จ

    ===========================

    getUrlData(string $url, string $userAgent=NULL)

    ํ•ด๋‹น url์—์„œ ๋ฐ˜ํ™˜ํ•œ ๊ฐ’์—์„œ ํ—ค๋”๋ฅผ ์ž˜๋ผ๋‚ธ๋’ค ์ถœ๋ ฅ

    ######Note ๋ฐ์ดํ„ฐ ๋กœ๋”ฉ์— ์‹คํŒจํ• ์‹œ NULL ๋ฐ˜ํ™˜

    #####Parameter

    • $url ์ •์˜๋œ url์œผ๋กœ http ํ†ต์‹ ์„ ํ•œ ๋’ค ๊ฒฐ๊ณผ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•จ
    • $userAgent ์„ค์ •์‹œ ํ•ด๋‹น userAgent๋ฅผ ์ฒจ๊ฐ€ํ•˜์—ฌ ์†ก์‹ 

    ===========================

    getServerInfo()

    config/server-info.json์—์„œ ์ •์˜๋œ ํ˜„์žฌ ์„œ๋ฒ„์˜ ์ •๋ณด๋ฅผ ๋ฐ˜ํ™˜

    ===========================

    getRelativeUrl()

    config/server-info.json ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ pmc ์—”์ง„์˜ ์ ˆ๋Œ€ ๊ฒฝ๋กœ๋ฅผ ๋ฐ˜ํ™˜

    ===========================

    getSessionDomain()

    config/server-info.json ์—์„œ ์ •์˜๋œ session_domain์„ ๋ฐ˜ํ™˜

    ######Note config/server-info.json ์—์„œ ์ •์˜๋˜์ง€ ์•Š์„ ์‹œ ํ˜„์žฌ์˜ http_host๋ฅผ ๋ฐ˜ํ™˜

    ===========================

    getUrl([string $module=NULL , string $action=NULL, object $queryParam=NULL, string $url=NULL])

    url ๊ด€๋ จ ์ •๋ณด๋ฅผ ๋ฐ˜ํ™˜

    #####Parameter

    • $module ์ •์˜์‹œ ํ•ด๋‹น ๋ชจ๋“ˆ์˜ ์ ˆ๋Œ€๊ฒฝ๋กœ๋ฅผ ๋ฐ˜ํ™˜ํ•จ
    • $action ์ •์˜์‹œ action์ด ํฌํ•จ๋œ ๋ชจ๋“ˆ์˜ ์ ˆ๋Œ€๊ฒฝ๋กœ ๋ฐ˜ํ™˜
    • $queryParame ๊นŒ์ง€ ์ •์˜์‹œ module, action ํŒŒ๋ผ๋ฏธํ„ฐ ๋’ค์— ์ถ”๊ฐ€ ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ’์„ ๋„ฃ์–ด ๋ฐ˜ํ™˜
    • $url ๊นŒ์ง€ ์ •์˜์‹œ RELAVITE_URL์ด ์•„๋‹Œ $url์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ’์„ ๋”ํ•ด์„œ ๋ฐ˜ํ™˜
    • $url์—์„œ ๋ฏธ๋ฆฌ ์ •์˜๋œ ํŒŒ๋ผ๋ฏธํ„ฐ ์ด๋ฆ„๊ณผ $queryParam ๋“ฑ์—์„œ ์ •์˜๋œ ํŒŒ๋ผ๋ฏธํ„ฐ ์ด๋ฆ„์ด ๊ฒน์น  ์‹œ $queryParam ๋“ฑ์—์„œ ์ •์˜๋œ ํŒŒ๋ผ๋ฏธํ„ฐ ๊ฐ’์ด ์šฐ์„ 
    • ์šฐ์„  ์ˆœ์œ„๋Š” module==action > queryParam > url
    • $module์ด NULL์ผ์‹œ #####Parameter $action์€ ๋ฌด์‹œ๋จ

    ===========================

    getUrlA(object $queryParam, string $url)

    getUrlํ•จ์ˆ˜์—์„œ #####Parameter $module, #####Parameter $action์ด ๋น ์ง„ ํ•˜์ˆ˜

    ===========================

    getCurrentUrl()

    ํ˜„์žฌ url ๋ฐ˜ํ™˜

    ===========================

    gegRealUrl([$module=NULL])

    ์‹ค์ œ url ๋ฐ˜ํ™˜ #####Parameter $module NULL์ผ์‹œ ํ˜„์žฌ url์„ ๋ฐ˜ํ™˜ํ•˜๋ฉฐ, NULL์ด ์•„๋‹์‹œ ํ•ด๋‹น ๋ชจ๋“ˆ์˜ ์‹ค์ œ url์„ ๋ฐ˜ํ™˜

    ===========================

    unparse_url(string $parsed_url)

    parse_url()์˜ ์—ญํ•จ์ˆ˜, getUrlA ํ•จ์ˆ˜์—์„œ ์“ฐ์ž„

    #####Parameter

    • $parsed_url ํŒŒ์‹ฑ๋œ url ๊ฐ์ฒด

    ===========================

    arrayToUrlQuery(array $array)

    array('param1' => 'val1', 'param2' => 'val2') ๊ฐ™์€ ๋ฐฐ์—ด์„ 'param1=val1&param2=val2' ์˜ string๊ฐ’์œผ๋กœ ๋ณ€ํ™˜ํ•จ

    #####Parameter

    • $array url ์ฟผ๋ฆฌ๋กœ ๋ณ€๊ฒฝ ํ•  ๋ฐฐ์—ด

    ===========================

    urlQueryToArray(string $query)

    arrayToUrlQuery() ์˜ ์—ญํ•จ์ˆ˜

    #####Note 'param1=val1&param2=val2' ๊ฐ™์€ ๋ฌธ์ž์—ด์„ array('param1' => 'val1', 'param2' => 'val2') ๊ฐ™์€ ๋ฐฐ์—ด ๊ฐ’์œผ๋กœ ๋ณ€ํ™˜ํ•จ

    #####Parameter

    • $query ๋ฐฐ์—ด๋กœ ๋ณ€๊ฒฝํ•  url ์ฟผ๋ฆฌ

    ===========================

    getBackUrl()

    ๋’ค๋กœ๊ฐ€๊ธฐ๋“ฑ์œผ๋กœ ์‚ฌ์šฉํ•  ์ด์ „ url์„ ๋ฐ˜ํ™˜ํ•จ

    ===========================

    redirect()

    url ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ

    ===========================

    goLogin()

    ๋กœ๊ทธ์ธ ํŽ˜์ด์ง€๋กœ ์ด๋™

    ===========================

    goBack($alertMessage=NULL, $clearContents=false)

    ๋’ค๋กœ ์ด๋™

    #####Parameter

    • $alertMessage : ์ •์˜์‹œ ํ•ด๋‹น ๋ฉ”์‹œ์ง€๋กœ ๊ฒฝ๊ณ ์ฐฝ์„ ํ•œ๋ฒˆ ๋›ฐ์šด ๋’ค ๋’ค๋กœ ์ด๋™
    • $clearContents : true์ผ๋•Œ ์ด์ „ ๋‚ด์šฉ์„ ob_clean ํ•œ ํ›„ ๋’ค๋กœ ์ด๋™

    ===========================

    getClearFileSize($size)

    ํŒŒ์ผ ์‚ฌ์ด์ฆˆ๋ฅผ ์˜ˆ์˜๊ฒŒ ์ถœ๋ ฅ

    ex) 36KB, 11MB, 5GB

    #####Parameter

    • $size : ํŒŒ์ผ ํฌํ‚ค (์ •์ˆ˜ํ˜•, ๋‹จ์œ„ : ๋ฐ”์ดํŠธ)

    ===========================

    removeXSS($content)

    XSS ํƒœ๊ทธ ์ œ๊ฑฐ

    #####Parameter

    • $content : HTML ์ฝ˜ํ…์ธ 
  • โš ๏ธ **GitHub.com Fallback** โš ๏ธ