Commit ea4fd5a5 authored by platyhouse's avatar platyhouse

Merge commit '9719b49b' as 'ptyLibrary_PHP'

parents ff12f5ed 9719b49b

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

<?php
namespace platyFramework;
/**
* ptyCliColor - CLI 색상 상수 정의 클래스
*
* 터미널에서 사용할 수 있는 다양한 색상 상수를 제공합니다.
*/
class ptyCliColor
{
// 기본 색상 (밝은 색상)
const LIGHT_WHITE = "\033[1;37m"; // 밝은 흰색
const RED = "\033[1;31m"; // 밝은 빨간색
const GREEN = "\033[1;32m"; // 밝은 녹색
const YELLOW = "\033[1;33m"; // 밝은 노란색
const BLUE = "\033[1;34m"; // 밝은 파란색
const MAGENTA = "\033[1;35m"; // 밝은 보라색
const CYAN = "\033[1;36m"; // 밝은 청록색
const BLACK = "\033[1;30m"; // 밝은 검정색 (회색)
// 일반 색상 (어두운 색상)
const DARK_WHITE = "\033[0;37m"; // 어두운 흰색
const DARK_RED = "\033[0;31m"; // 어두운 빨간색
const DARK_GREEN = "\033[0;32m"; // 어두운 녹색
const DARK_YELLOW = "\033[0;33m"; // 어두운 노란색
const DARK_BLUE = "\033[0;34m"; // 어두운 파란색
const DARK_MAGENTA = "\033[0;35m"; // 어두운 보라색
const DARK_CYAN = "\033[0;36m"; // 어두운 청록색
const DARK_BLACK = "\033[0;30m"; // 어두운 검정색
// 배경 색상
const BG_WHITE = "\033[47m"; // 흰색 배경
const BG_RED = "\033[41m"; // 빨간색 배경
const BG_GREEN = "\033[42m"; // 녹색 배경
const BG_YELLOW = "\033[43m"; // 노란색 배경
const BG_BLUE = "\033[44m"; // 파란색 배경
const BG_MAGENTA = "\033[45m"; // 보라색 배경
const BG_CYAN = "\033[46m"; // 청록색 배경
const BG_BLACK = "\033[40m"; // 검정색 배경
// 특수 스타일
const BOLD = "\033[1m"; // 굵게
const DIM = "\033[2m"; // 흐리게
const ITALIC = "\033[3m"; // 기울임
const UNDERLINE = "\033[4m"; // 밑줄
const BLINK = "\033[5m"; // 깜빡임
const REVERSE = "\033[7m"; // 반전
const HIDDEN = "\033[8m"; // 숨김
// 리셋
const RESET = "\033[0m"; // 모든 스타일 리셋
// 자주 사용하는 조합 색상
const SUCCESS = self::GREEN; // 성공 (녹색)
const ERROR = self::RED; // 에러 (빨간색)
const WARNING = self::YELLOW; // 경고 (노란색)
const INFO = self::CYAN; // 정보 (청록색)
const DEBUG = self::MAGENTA; // 디버그 (보라색)
/**
* 텍스트에 색상 적용
*
* @param string $text 텍스트
* @param string $color 색상 상수
* @return string 색상이 적용된 텍스트
*/
public static function colorize($text, $color)
{
return $color . $text . self::RESET;
}
/**
* 사용 가능한 모든 색상 출력
*/
public static function showAllColors()
{
$colors = [
'WHITE' => self::WHITE,
'RED' => self::RED,
'GREEN' => self::GREEN,
'YELLOW' => self::YELLOW,
'BLUE' => self::BLUE,
'MAGENTA' => self::MAGENTA,
'CYAN' => self::CYAN,
'BLACK' => self::BLACK,
];
echo "\n=== 밝은 색상 ===\n";
foreach ($colors as $name => $code) {
echo self::colorize("$name: This is a sample text", $code) . "\n";
}
echo "\n=== 어두운 색상 ===\n";
$darkColors = [
'DARK_WHITE' => self::DARK_WHITE,
'DARK_RED' => self::DARK_RED,
'DARK_GREEN' => self::DARK_GREEN,
'DARK_YELLOW' => self::DARK_YELLOW,
'DARK_BLUE' => self::DARK_BLUE,
'DARK_MAGENTA' => self::DARK_MAGENTA,
'DARK_CYAN' => self::DARK_CYAN,
'DARK_BLACK' => self::DARK_BLACK,
];
foreach ($darkColors as $name => $code) {
echo self::colorize("$name: This is a sample text", $code) . "\n";
}
echo "\n=== 자주 사용하는 조합 ===\n";
echo self::colorize("SUCCESS: 작업이 성공적으로 완료되었습니다.", self::SUCCESS) . "\n";
echo self::colorize("ERROR: 오류가 발생했습니다.", self::ERROR) . "\n";
echo self::colorize("WARNING: 경고 메시지입니다.", self::WARNING) . "\n";
echo self::colorize("INFO: 정보 메시지입니다.", self::INFO) . "\n";
echo self::colorize("DEBUG: 디버그 메시지입니다.", self::DEBUG) . "\n";
}
}
\ No newline at end of file
<?php
namespace platyFramework;
require_once __DIR__ . '/ptyCliColor.php';
class ptyCliLog
{
// 하위 호환성을 위한 색상 상수 (ptyCliColor 사용 권장)
const COLOR_WHITE = ptyCliColor::LIGHT_WHITE;
const COLOR_RED = ptyCliColor::RED;
const COLOR_GREEN = ptyCliColor::GREEN;
const COLOR_YELLOW = ptyCliColor::YELLOW;
const COLOR_BLUE = ptyCliColor::BLUE;
const COLOR_MAGENTA = ptyCliColor::MAGENTA;
const COLOR_CYAN = ptyCliColor::CYAN;
const COLOR_RESET = ptyCliColor::RESET;
private $prefix;
private $color;
private $debug;
private $colors;
public function __construct($prefix = "APP", $color = ptyCliColor::LIGHT_WHITE, $debug = true)
{
$this->prefix = $prefix;
$this->color = $color;
$this->debug = $debug;
$this->colors = [
'info' => ptyCliColor::CYAN,
'success' => ptyCliColor::GREEN,
'warning' => ptyCliColor::YELLOW,
'error' => ptyCliColor::RED,
'url' => ptyCliColor::MAGENTA,
'verbose' => ptyCliColor::DARK_WHITE,
'data' => ptyCliColor::LIGHT_WHITE,
'response' => ptyCliColor::CYAN,
'reset' => ptyCliColor::RESET
];
date_default_timezone_set('Asia/Seoul');
if ($prefix != "URL" && $prefix != "ELASTIC") {
$this->url = new ptyCliLog("URL", ptyCliColor::DARK_MAGENTA, $debug);
$this->elastic = new ptyCliLog("URL", ptyCliColor::DARK_WHITE, $debug);
}
}
public function log($message, $type = 'info', $data = null)
{
if (!$this->debug) return;
if ($message == "") {
echo "\n";
return;
}
// 타임스탬프 생성 (밀리초 포함)
$now = microtime(true);
// $milliseconds = sprintf("%03d", ($now - floor($now)) * 1000);
// $timestamp = date('Y-m-d H:i:s', (int)$now) . '.' . $milliseconds;
$timestamp = date('H:i:s', (int)$now);
$typeColor = $this->colors[$type] ?? $this->colors['info'];
$reset = $this->colors['reset'];
// verbose 타입일 때 호출한 함수명 추가
$functionName = "";
// if ($type === 'verbose') {
if (true) {
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
if (isset($backtrace[2])) {
$caller = $backtrace[2];
if (isset($caller['class'])) {
$functionName = $caller['class'] . $caller['type'] . $caller['function'];
} else if (isset($caller['function'])) {
$functionName = $caller['function'];
}
if ($functionName) {
// closure인 경우 파일명:라인번호 형식으로 변환
if (preg_match('/\{closure:(.+):(\d+)\}/', $functionName, $matches)) {
$filePath = $matches[1];
$lineNumber = $matches[2];
$fileName = basename($filePath);
$functionName = $fileName . ':' . $lineNumber;
}
else {
$functionName.= "()";
}
$functionName = ptyCliColor::DARK_WHITE . $functionName . " ". $reset;
}
}
}
// 타임스탬프 + prefix에 지정된 색상 사용, type은 타입 색상 사용
echo ptyCliColor::DARK_WHITE . $timestamp . " " . $reset;
echo sprintf("%-45s", $functionName);
echo $this->color . sprintf("[%-8s] ", strtoupper($this->prefix)) . $reset;
echo $typeColor . $message . $reset . "\n";
if ($data !== null) {
echo $this->colors['data'] . json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . $reset . "\n";
}
}
public function verbose($message, $data = null)
{
$this->log($message, 'verbose', $data);
}
public function info($message, $data = null)
{
$this->log($message, 'info', $data);
}
public function success($message, $data = null)
{
$this->log($message, 'success', $data);
}
public function warning($message, $data = null)
{
$this->log($message, 'warning', $data);
}
public function error($message, $data = null)
{
$this->log($message, 'error', $data);
}
public function url($message, $data = null)
{
$this->log($message, 'url', $data);
}
public function mysql($message, $data = null)
{
$this->log($message, 'mysql', $data);
}
public function elastic($message, $data = null)
{
$this->log($message, 'elastic', $data);
}
public function data($message, $data = null)
{
$this->log($message, 'data', $data);
}
public function response($message, $data = null)
{
$this->log($message, 'response', $data);
}
public function setDebug($debug)
{
$this->debug = $debug;
$this->log("디버그 모드 " . ($debug ? "활성화" : "비활성화"), 'info');
}
public function isDebugEnabled()
{
return $this->debug;
}
public function separator($length = 50)
{
$this->log("\n".str_repeat("=", $length), 'info');
}
}
/**
* ptyCliLog 헬퍼 함수
*
* @param string $prefix 로그 prefix (기본값: "APP")
* @param string $color 로그 색상 (기본값: ptyCliLog::COLOR_WHITE)
* @param bool $debug 디버그 모드 (기본값: true)
* @return ptyCliLog
*/
function ptyCliLog($prefix = "APP", $color = ptyCliLog::COLOR_WHITE, $debug = true)
{
return new ptyCliLog($prefix, $color, $debug);
}
\ No newline at end of file
<?php
namespace platyFramework;
class ptyAes256
{
function encrypt($plain_text, $key)
{
return base64_encode(openssl_encrypt($plain_text, "aes-256-cbc", $key, TRUE, str_repeat(chr(0), 16)));
}
function decrypt($base64_text, $key)
{
return openssl_decrypt(base64_decode($base64_text), "aes-256-cbc", $key, TRUE, str_repeat(chr(0), 16));
}
/*
function encrypt_noopenssl($key, $value)
{
$padSize = 16 - (strlen($value) % 16);
$value = $value . str_repeat(chr($padSize), $padSize);
$output = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $value, MCRYPT_MODE_CBC, str_repeat(chr(0), 16));
return base64_encode($output);
}
function decrypt_noopenssl($key, $value)
{
$value = base64_decode($value);
$output = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $value, MCRYPT_MODE_CBC, str_repeat(chr(0), 16));
$valueLen = strlen($output);
if ($valueLen % 16 > 0)
$output = "";
$padSize = ord($output{$valueLen - 1});
if (($padSize < 1) or ($padSize > 16))
$output = ""; // Check padding.
for ($i = 0; $i < $padSize; $i++) {
if (ord($output{$valueLen - $i - 1}) != $padSize)
$output = "";
}
$output = substr($output, 0, $valueLen - $padSize);
return $output;
}
*/
}
?>
\ No newline at end of file
<?php
namespace platyFramework;
class ptyAppErrorModel
{
var $tableName = "t_platy_error_logs";
public function __construct()
{
$this->_checkTableExistsAndCreate();
}
function _checkTableExistsAndCreate()
{
GLOBAL $platyFramework;
$this->db = $platyFramework->db;
if (!$this->db->sql_result("SHOW TABLES LIKE '$this->tableName'")) {
$this->db->sql_query("
CREATE TABLE IF NOT EXISTS `{$this->tableName}` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`regDateTime` datetime NULL,
`ip` varchar(64) COLLATE utf8mb4_unicode_ci NULL,
`userAgent` varchar(128) COLLATE utf8mb4_unicode_ci NULL,
`errorType` varchar(32) COLLATE utf8mb4_unicode_ci NULL,
`errorMessage` longtext COLLATE utf8mb4_unicode_ci NULL,
`errorFileName` varchar(128) COLLATE utf8mb4_unicode_ci NULL,
`errorLine` varchar(32) COLLATE utf8mb4_unicode_ci NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1;
");
}
if (!$this->db->sql_result("SHOW COLUMNS FROM `{$this->tableName}` LIKE 'requestUrl'")) {
$this->db->sql_query("ALTER TABLE `{$this->tableName}` ADD `requestUrl` longtext null;");
}
}
public function insert($num, $str, $file, $line)
{
$fullUrl = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$str = ptyCutLength($str, 2000);
GLOBAL $platyFramework;
$n = $platyFramework->db->query("INSERT INTO {$this->tableName} (regDateTime, ip, userAgent, errorType, errorMessage, errorFileName, errorLine, requestUrl) VALUES
(NOW(), '{$_SERVER['REMOTE_ADDR']}', '{$_SERVER['HTTP_USER_AGENT']}',
'" . addslashes($num) . "',
'" . addslashes($str) . "',
'" . addslashes($file) . "',
'" . addslashes($line) . "',
'" . addslashes(ptyCutLength($fullUrl, 65000)) . "'
)");
if ($n)
echo "error reported.<br>";
else
echo "error cannot reported.<br>";
}
}
?>
This diff is collapsed.
<?php
/**
* Created by PhpStorm.
* User: cpueblo
* Date: 2016. 8. 30.
* Time: 오후 4:56
*/
namespace platyFramework;
class ptyDBListModel extends model
{
public $_tableName;
public $itemModelClassName;
public $pageName;
public $itemsPerPage;
private $totalCount;
function __construct($tableName, $itemModelClassName, $pageName = "page", $itemsPerPage = 0)
{
parent::__construct();
$this->_tableName = $tableName;
$this->itemModelClassName = $itemModelClassName;
$this->pageName = $pageName;
$this->itemsPerPage = $itemsPerPage;
$this->init();
}
function init($enabled = true)
{
$this->db->clear();
$this->db->addSelect("*");
$this->db->addFrom($this->_tableName);
if ($enabled)
$this->db->addWhereEqual("enabled", "1");
return $this;
}
function addWhereEnabled()
{
$this->db->addWhereEqual("enabled", "1");
return $this;
}
function getItemBy($key, $value)
{
$this->db->addWhereEqual($key, $value);
return $this->getItem();
}
function addWhere($values)
{
// $this->db->addWhere()
// $this->db->addWhere($values);
}
function get()
{
if ($this->itemsPerPage && $this->pageName) {
$this->db->pageName = $this->pageName;
$this->db->setLimit($this->itemsPerPage);
$this->totalCount = $this->db->getCount();
}
$lst = $this->db->sql_list ();
$lst = $this->buildWithItems($lst);
return $lst;
}
function getItem()
{
$this->db->setLimit(0);
$item = $this->db->sql_fetch();
if ($item) {
$className = $this->itemModelClassName;
return $className::build($item);
}
else
{
return null;
}
}
public function buildWithItems($items)
{
$ret = array();
$className = $this->itemModelClassName;
foreach ($items as $k => $v) {
$ret[] = $className::build($v);
}
return $ret;
}
public function getPaging($maxPagesToShow = 10)
{
if ($this->itemsPerPage == 0) return "";
$page = (int)$this->request->request[$this->pageName];
if ($page == 0)
$page = 1;
$p = new Paginator($this->totalCount, $this->itemsPerPage, $page, '');
$p->setMaxPagesToShow($maxPagesToShow);
$first = ptyRebuildUrl(array($this->pageName => 1));
$prev = ptyRebuildUrl(array($this->pageName => $p->getPrevPage() ? $p->getPrevPage() : 1));
$next = ptyRebuildUrl(array($this->pageName => $p->getNextPage() ? $p->getNextPage() : $p->getNumPages()));
$last = ptyRebuildUrl(array($this->pageName => $p->getNumPages()));
$out = "<ul class='pull-right pagination clearfix'>";
$out .= "<li class='prev'><a href='$first' class='first'>처음</a></li>";
$out .= "<li class='prev'><a href='$prev' class='prev'>이전</a></li>";
foreach ($p->getPages() as $item) {
if ($item['num'] == "...")
$url = "";
else
$url = ptyRebuildUrl(array($this->pageName => $item['num']));
if ($item[isCurrent])
$out .= "<li class='active'><a href='$url'>" . $item[num] . "</a></li>";
else
$out .= "<li><a href='$url'>" . $item[num] . "</a></li>";
}
$out .= "<li class='next'><a href='$next' class='next'>다음</a></li>";
$out .= "<li class='prev'><a href='$last' class='last'>마지막</a></li>";
$out .= "</ul>";
return $out;
}
public function remove($id)
{
$this->db->clear()->addFrom($this->_tableName)->addWhere("id = '$id'")->addSet("enabled = 0")->update();
}
public function delete($id)
{
$this->db->clear()->addFrom($this->_tableName)->addWhere("id = '$id'")->delete();
}
public function insert($item)
{
/** @var ptyDBItem $item */
$this->db->clear()->addFrom($this->_tableName)->addSet($item->_item)->insert();
$item->id = $this->db->getInsertId();
return $item->id;
}
}
This diff is collapsed.
<?php
/**
* Created by PhpStorm.
* User: cpueblo
* Date: 2016. 8. 30.
* Time: 오후 4:56
*/
namespace platyFramework;
class ptyDBItemManager extends model
{
var $pageLimit = 0;
var $_tableName = "";
public function __construct($tableName)
{
parent::__construct();
$this->_tableName = $tableName;
}
function init()
{
$this->db->clear();
$this->db->addFrom($this->_tableName);
return $this;
}
function adminInit()
{
$this->db->clear();
$this->db->addFrom($this->_tableName);
return $this;
}
function getTotalCount()
{
GLOBAL $db;
$this->db->clear()->addSelect("COUNT(*)")->addFrom($this->_tableName)->addWhere("enabled = '1'");
return $this->db->getCount();
}
public function getItemById($id)
{
GLOBAL $db;
$this->db->clear()->addSelect("*")->addFrom($this->_tableName)->addWhere("id = '$id'");
$data = $this->db->sql_fetch();
if (!$data)
return null;
$item = new ptyDBItem($this->_tableName, $data);
return $item;
}
public function getItemBy($key, $value)
{
GLOBAL $db;
$this->db->clear()->addSelect("*")->addFrom($this->_tableName)->addWhere("$key = '$value'");
$data = $this->db->sql_fetch();
if (!$data)
return null;
$item = new ptyDBItem($this->_tableName, $data);
return $item;
}
public function getItemByArray($array)
{
$this->db->clear()->addSelect("*")->addFrom($this->_tableName);
foreach ($array as $k => $v) {
if ($k && $v)
$this->db->addWhereEqual($k, $v);
}
$data = $this->db->sql_fetch();
if (!$data)
return null;
$item = new ptyDBItem($this->_tableName, $data);
return $item;
}
public function remove($id)
{
$this->db->clear()->addFrom($this->_tableName)->addWhere("id = '$id'")->addSet("enabled = 0")->update();
}
public function delete($id)
{
$this->db->clear()->addFrom($this->_tableName)->addWhere("id = '$id'")->delete();
}
public function add($data)
{
$this->db->clear()->addFrom($this->_tableName)->addSet($data)->insert();
return $this->db->getInsertId();
}
function get($wheres = null, $orderBy = null)
{
$lst = $this->getRaw($wheres, $orderBy);
$lst = ptyDBItem::buildWithItems($lst);
return $lst;
}
function getRaw($wheres = null, $orderBy = null)
{
$this->init();
if ($this->pageLimit)
$this->db->setLimit($this->pageLimit);
foreach ($wheres as $k => $v) {
if (isset($k) && isset($v) && !is_null($v)) {
$this->db->addWhereEqual($k, $v);
}
else if (isset($k)) {
$this->db->addWhere($k);
}
}
if (is_null($orderBy))
$this->db->addOrderBy("id desc");
else
{
foreach ($orderBy as $o)
$this->db->addOrderBy($o);
}
$this->totalCount = $this->getTotalCount();
// echo "totalCnt = ".$this->totalCount;
$lst = $this->db->addSelect($this->_tableName . ".*")->sql_list();
return $lst;
}
function getPaging()
{
if ($this->pageLimit == 0) return;
// pg ==> board paging
$page = (int)$this->request->request['pg'];
if ($page == 0)
$page = 1;
$p = new Paginator($this->totalCount, $this->pageLimit, $page, '');
$p->setMaxPagesToShow($this->pageLimit);
$first = ptyRebuildUrl(array("pg" => 1));
$prev = ptyRebuildUrl(array("pg" => $p->getPrevPage() ? $p->getPrevPage() : 1));
$next = ptyRebuildUrl(array("pg" => $p->getNextPage() ? $p->getNextPage() : $p->getNumPages()));
$last = ptyRebuildUrl(array("pg" => $p->getNumPages()));
$out = "<a href='$first' class='first'>처음</a>";
$out .= "<a href='$prev' class='prev'>이전</a>";
foreach ($p->getPages() as $item) {
$url = ptyRebuildUrl(array("pg" => $item['num']));
if ($item[isCurrent])
$out .= "<a href='$url' class='on'>" . $item[num] . "</a>";
else
$out .= "<a href='$url'>" . $item[num] . "</a>";
}
$out .= "<a href='$next' class='next'>다음</a>";
$out .= "<a href='$last' class='last'>마지막</a>";
return $out;
}
function getCurrentPageNo()
{
if ($this->pageLimit == 0) return 1;
// pg ==> board paging
$page = (int)$this->request->request['pg'];
if ($page == 0) $page = 1;
$p = new Paginator($this->totalCount, $this->pageLimit, $page, '');
$p->setMaxPagesToShow($this->pageLimit);
return $p->getCurrentPage();
}
function hasMorePaging()
{
if ($this->pageLimit == 0) return false;
// pg ==> board paging
$page = (int)$this->request->request['pg'];
if ($page == 0) $page = 1;
$p = new Paginator($this->totalCount, $this->pageLimit, $page, '');
$p->setMaxPagesToShow($this->pageLimit);
if ($p->getCurrentPage() != $p->getNumPages())
return true;
else
return false;
}
}
class ptyDBItem extends ptyItem
{
var $db;
var $tableName = "";
public function __construct($tableName, $item = "")
{
GLOBAL $platyFramework;
$this->db = $platyFramework->db;
parent::__construct($item);
$this->tableName = $tableName;
$this->init();
}
public static function buildItemById($tableName, $id)
{
$item = new static($tableName);
// $item->db->setDebug(1);
$item->db->clear()->addSelect("*")->addFrom($item->tableName)->addWher("id = '$id'");
$data = $item->db->sql_fetch();
if (!$data)
return null;
$item->_item = $data;
return $item;
}
public static function buildItemBy($tableName, $by, $value)
{
$item = new static($tableName);
$item->db->clear()->addSelect("*")->addFrom($item->tableName)->addWhere("$by = '$value'");
$data = $item->db->sql_fetch();
if (!$data)
return null;
$item->_item = $data;
return $item;
}
public function init()
{
$this->db->clear();
return $this;
}
public function insert()
{
$this->db->clear()
->addFrom($this->tableName)
->addSet($this->_item)
->insert();
$this->id = $this->db->getInsertId();
return $this->id;
}
public function update()
{
GLOBAL $db;
$this->db->clear();
foreach ($this->_item as $k => $v) {
if (!isset($v)) $v = '';
if ($k == "id")
continue;
$this->db->addSet($k, $v);
}
$this->db->addFrom($this->tableName)
->addWhereEqual("id", $this->id)
->update();
}
}
/**
* Class ptyItem
*
* Getter 와 Setter 를 배열에서 객체로 변환하여 사용하게 합니다.
* 주의 : 없는 변수에 대해서는 null 이 아닌 "" 를 리턴합니다
*
* @package platyFramework
* @author cpueblo <cpueblo@platyhouse.com>
*/
abstract class ptyList
{
protected $_items;
public function __construct($lst)
{
}
public function getCount()
{
return count($this->_items);
}
public function getItems()
{
return $this->_items;
}
public function getArrayItems()
{
$ret = array();
foreach ($this->_items as $item) {
$ret[] = $item->_item;
}
return $ret;
}
public function addLists($n)
{
if (!isset($this->_items))
$this->_items = array();
$this->_items = array_merge($this->_items, $n->_items);
}
public function addItem($item)
{
$this->_items[] = $item;
}
}
\ No newline at end of file
This diff is collapsed.
<?php
namespace platyFramework;
class ptyDateTime
{
}
/**
* 과거일 경우 -, 지났을 경우 +
*
* @param string $datetime
* @return int|null
*/
function ptyGetPassedMinutes(string $datetime)
{
try {
// 현재 시간 가져오기
$now = new \DateTime();
// 입력된 날짜를 DateTime 객체로 변환
$date = new \DateTime($datetime);
// 현재 시간과 입력된 시간의 차이를 계산
$diff = $now->getTimestamp() - $date->getTimestamp();
$passMinute = floor($diff / 60); // 초 단위 차이를 분 단위로 변환
return (int)$passMinute;
} catch (\Exception $e) {
// 예외 발생 시 false 반환, $passMinute은 -1로 설정
return null;
}
}
/**
* 일자만으로 차이 비교, 과거일 경우 -, 지났을 경우 +
*
* @param string $datetime
* @return int|null
*/
function ptyGetPassedDay(string $datetime)
{
try {
$date = new \DateTime($datetime);
$datetime = $date->format('Y-m-d');
// 현재 시간 가져오기
$now = new \DateTime();
// 입력된 날짜를 DateTime 객체로 변환
$date = new \DateTime($datetime);
// 현재 시간과 입력된 시간의 차이를 계산
$diff = $now->diff($date);
// 날짜 차이를 일(day) 단위로 반환
$passDays = (int)$diff->format('%r%a'); // %r: 음수일 경우 부호를 유지, %a: 전체 일 수
return (int)$passDays;
} catch (\Exception $e) {
// 예외 발생 시 false 반환, $passMinute은 -1로 설정
return null;
}
}
/**
* 특정 시간의 '오전', '오후' 리턴
* @param string $s
* @return string '오전, 오후"
* @throws \DateMalformedStringException
*/
function ptyGetAmPm(string $s)
{
return ($amPm = (new \DateTime($s))->format('A') === 'AM' ? '오전' : '오후') . ' ' . (new \DateTime($s))->format('g시 i분');
}
?>
\ No newline at end of file
<?php
namespace platyFramework;
class ptyElapsedTime
{
private $startTime;
public function __construct()
{
$this->startTime = microtime(true);
}
/**
* 경과 시간을 밀리초(ms) 단위로 반환
* @return int 경과 시간 (밀리초)
*/
public function get()
{
$endTime = microtime(true);
$elapsedSeconds = $endTime - $this->startTime;
return round($elapsedSeconds * 1000); // 초를 밀리초로 변환 후 반올림
}
/**
* 시작 시간을 현재 시간으로 리셋
*/
public function reset()
{
$this->startTime = microtime(true);
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation;
class CalculationBase
{
/**
* Get a list of all implemented functions as an array of function objects.
*
* @return array<string, array{category: string, functionCall: string|string[], argumentCount: string, passCellReference?: bool, passByReference?: bool[], custom?: bool}>
*/
public static function getFunctions(): array
{
return FunctionArray::$phpSpreadsheetFunctions;
}
/**
* Get address of list of all implemented functions as an array of function objects.
*
* @return array<string, array<string, mixed>>
*/
protected static function &getFunctionsAddress(): array
{
return FunctionArray::$phpSpreadsheetFunctions;
}
/**
* @param array{category: string, functionCall: string|string[], argumentCount: string, passCellReference?: bool, passByReference?: bool[], custom?: bool} $value
*/
public static function addFunction(string $key, array $value): bool
{
$key = strtoupper($key);
if (array_key_exists($key, FunctionArray::$phpSpreadsheetFunctions)) {
return false;
}
$value['custom'] = true;
FunctionArray::$phpSpreadsheetFunctions[$key] = $value;
return true;
}
public static function removeFunction(string $key): bool
{
$key = strtoupper($key);
if (array_key_exists($key, FunctionArray::$phpSpreadsheetFunctions)) {
if (FunctionArray::$phpSpreadsheetFunctions[$key]['custom'] ?? false) {
unset(FunctionArray::$phpSpreadsheetFunctions[$key]);
return true;
}
}
return false;
}
}
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation;
abstract class Category
{
// Function categories
const CATEGORY_CUBE = 'Cube';
const CATEGORY_DATABASE = 'Database';
const CATEGORY_DATE_AND_TIME = 'Date and Time';
const CATEGORY_ENGINEERING = 'Engineering';
const CATEGORY_FINANCIAL = 'Financial';
const CATEGORY_INFORMATION = 'Information';
const CATEGORY_LOGICAL = 'Logical';
const CATEGORY_LOOKUP_AND_REFERENCE = 'Lookup and Reference';
const CATEGORY_MATH_AND_TRIG = 'Math and Trig';
const CATEGORY_STATISTICAL = 'Statistical';
const CATEGORY_TEXT_AND_DATA = 'Text and Data';
const CATEGORY_WEB = 'Web';
const CATEGORY_UNCATEGORISED = 'Uncategorised';
const CATEGORY_MICROSOFT_INTERNAL = 'MS Internal';
}
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
class Constants
{
// Constants currently used by WeekNum; will eventually be used by WEEKDAY
const STARTWEEK_SUNDAY = 1;
const STARTWEEK_MONDAY = 2;
const STARTWEEK_MONDAY_ALT = 11;
const STARTWEEK_TUESDAY = 12;
const STARTWEEK_WEDNESDAY = 13;
const STARTWEEK_THURSDAY = 14;
const STARTWEEK_FRIDAY = 15;
const STARTWEEK_SATURDAY = 16;
const STARTWEEK_SUNDAY_ALT = 17;
const DOW_SUNDAY = 1;
const DOW_MONDAY = 2;
const DOW_TUESDAY = 3;
const DOW_WEDNESDAY = 4;
const DOW_THURSDAY = 5;
const DOW_FRIDAY = 6;
const DOW_SATURDAY = 7;
const STARTWEEK_MONDAY_ISO = 21;
const METHODARR = [
self::STARTWEEK_SUNDAY => self::DOW_SUNDAY,
self::DOW_MONDAY,
self::STARTWEEK_MONDAY_ALT => self::DOW_MONDAY,
self::DOW_TUESDAY,
self::DOW_WEDNESDAY,
self::DOW_THURSDAY,
self::DOW_FRIDAY,
self::DOW_SATURDAY,
self::DOW_SUNDAY,
self::STARTWEEK_MONDAY_ISO => self::STARTWEEK_MONDAY_ISO,
];
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment