This commit is contained in:
2018-01-09 19:54:49 +09:00
commit 7b3201548a
518 changed files with 174188 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
<?
define(ROOT, '..');
require_once(ROOT.'/f_config/config.php');
require_once(ROOT.W.F_CONFIG.W.APP.PHP);
require_once(ROOT.W.F_FUNC.W.FUNC.PHP);
CustomHeader();
?>
+27
View File
@@ -0,0 +1,27 @@
<?
require_once('_common.php');
require_once(ROOT.'/f_config/config.php');
require_once(ROOT.W.F_FUNC.W.'class._DB.php');
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
class _Chat {
public static function SetChat($type, $name, $msg) {
$filename = ROOT.W.D_CHAT.W.$type."Chat.txt";
AppendToFile($filename, "{$name}: {$msg}\r\n");
}
public static function GetChat($type, $size=10) {
$filename = ROOT.W.D_CHAT.W.$type."Chat.txt";
$content = ReadToFileBackward($filename, $size*100);
$msgs = explode("\r\n", $content);
$count = count($msgs) - 1;
$start = $count - $size;
if($start < 0) $start = 0;
for($i = $start; $i < $count; $i++) {
$newMsg[] = htmlspecialchars($msgs[$i]);
}
return $newMsg;
}
}
?>
+145
View File
@@ -0,0 +1,145 @@
<?
require_once('_common.php');
require_once(ROOT.W.E_LIB.W.'adodb5/adodb.inc.php');
class _DB {
private $objDB;
private $setting = 'none';
public function __construct($host, $id, $pw, $db) {
$this->objDB = ADONewConnection('mysqli'); // 예 'mysql' 또는 'postgres'
// $this->objDB->debug = true;
$this->objDB->debug = false;
$this->objDB->Connect($host, $id, $pw, $db) or Error('DB Connect() error: '.$db);
// 성능을 고려해 PConnect 조사
$this->objDB->SetFetchMode(ADODB_FETCH_ASSOC);
$this->objDB->Execute('set names utf8');
$this->setting = "{$host}//{$id}//{$db}";
}
public function GetSetting() {
return $this->setting;
}
public function QueryNoError($strQuery) {
return $this->objDB->Execute($strQuery);
}
public function Query($strQuery) {
$rs = $this->objDB->Execute($strQuery) or Error($strQuery);
return $rs;
}
public function Count($rs) {
if($rs == null) {
return 0;
}
return $rs->RecordCount();
}
public function HasNext($rs) {
return !$rs->EOF;
}
public function GetAll($rs) {
return $rs->GetRows();
}
public function Get($rs) {
return $rs->fields;
}
public function MoveNext($rs) {
$rs->MoveNext();
}
public function Next($rs) {
$obj = $rs->fields;
$rs->MoveNext();
return $obj;
}
public function Select($strFields, $strTable, $strCondition=NULL, $strGroupByField=NULL, $strHavingCondition=NULL) {
$strQuery = "SELECT {$strFields} FROM {$strTable}";
if($strCondition != NULL) {
$strQuery .= " WHERE {$strCondition}";
if($strGroupByField != NULL) {
$strQuery .= " GROUP BY {$strGroupByField}";
if($strHavingCondition != NULL) {
$strQuery .= " HAVING {$strHavingCondition}";
}
}
}
return $this->objDB->Execute($strQuery);
}
public function Insert($strTable, $strFields, $strValues) {
$strQuery = "INSERT INTO {$strTable} ({$strFields}) VALUES ({$strValues})";
$this->objDB->Execute($strQuery);
}
public function InsertArray($strTable, $arrVals) {
$arrFields = array();
$arrValues = array();
foreach($arrVals as $strKey => $strVal) {
$arrFields[] = $strKey;
$arrValues[] = $strVal;
}
$strFields = implode(',', $arrFields);
$strValues = implode("','", $arrValues);
$strValues = "'".$strValues."'";
$strQuery = "INSERT INTO {$strTable} ({$strFields}) VALUES ({$strValues})";
$this->objDB->Execute($strQuery);
}
public function Update($strTable, $strSetting, $strCondition=NULL) {
$strQuery = "UPDATE {$strTable} SET {$strSetting}";
if($strCondition != NULL) {
$strQuery .= " WHERE {$strCondition}";
}
$this->objDB->Execute($strQuery);
}
public function UpdateArray($strTable, $arrVals, $strCondition=NULL) {
$arrSetting = array();
foreach($arrVals as $strKey => $strVal) {
$arrSetting[] = "{$strKey}='{$strVal}'";
}
$strSetting = implode(',', $arrSetting);
$strQuery = "UPDATE {$strTable} SET {$strSetting}";
if($strCondition != NULL) {
$strQuery .= " WHERE {$strCondition}";
}
$this->objDB->Execute($strQuery);
}
public function Delete($strTable, $strCondition=NULL) {
$strQuery = "DELETE FROM {$strTable}";
if($strCondition != NULL) {
$strQuery .= " WHERE {$strCondition}";
}
$this->objDB->Execute($strQuery);
}
public function __destruct() {
$this->objDB->Close();
}
public function Qstr($str) {
return $this->objDB->qstr($str);
}
}
?>
+55
View File
@@ -0,0 +1,55 @@
<?
class _JSON {
public static function Encode($arr) {
foreach($arr as $key => $val) {
$key = _JSON::AddSlashes($key);
if(is_array($val) == true) {
$val = json_encode($val);
} else {
$val = _JSON::AddSlashes($val);
}
$item[] = "\"{$key}\":\"{$val}\"";
}
$encoded = '{' . implode(',', $item) . '}';
return $encoded;
}
public static function Decode($encoded) {
$decoded = substr($encoded, 2, strlen($encoded)-4);
$len = strlen($decoded);
$s = 0; $e = 0;
while($s < $len) {
$e = strpos($decoded, '":"', $s);
$key = substr($decoded, $s, $e-$s);
$s = $e + 3;
$e = strpos($decoded, '","', $s);
if($e == false) $e = $len;
$val = substr($decoded, $s, $e-$s);
if(substr($val, 0, 2) != '{"') {
$s = $e + 3;
} else {
$e = strpos($decoded, '"}"', $s) + 2;
$val = substr($decoded, $s, $e-$s);
$s = $e + 3;
$val = json_decode($val);
}
$result[$key] = $val;
}
return $result;
}
public static function AddSlashes($str) {
$str = str_replace("\\", "\\\\", $str);
$str = str_replace("\"", "\\\"", $str);
$str = str_replace("'", "\\'", $str);
$str = str_replace("\r\n", "\\n", $str);
$str = str_replace("\n", "\\n", $str);
return $str;
}
}
?>
+73
View File
@@ -0,0 +1,73 @@
<?
require_once('_common.php');
require_once(ROOT.'/f_config/config.php');
class _Lock {
private static $l = ROOT.W.'lock.txt';
public static function Busy() {
$fp = fopen(_Lock::$l, 'r');
$lock = fread($fp, 1);
fclose($fp);
if($lock == 1) return true;
else return false;
}
private static function LockFile() {
$fp = fopen(_Lock::$l, 'r');
$lock = fread($fp, 1);
fclose($fp);
if($lock == 1) return false;
$fp = fopen(_Lock::$l, 'w');
if(!flock($fp, LOCK_EX)) { return false; }
fwrite($fp, '1');
fclose($fp);
flock($fp, LOCK_UN);
return true;
}
private static function UnlockFile() {
$fp = fopen(_Lock::$l, 'r');
$lock = fread($fp, 1);
fclose($fp);
if($lock == 0) return false;
$fp = fopen(_Lock::$l, 'w');
if(!flock($fp, LOCK_EX)) { return false; }
fwrite($fp, '0');
fclose($fp);
flock($fp, LOCK_UN);
return true;
}
public static function Lock() {
/*
// 키 생성
$key = fileinode(_Lock::$l);
// 뮤텍스 획득
$mutex = sem_get($key);
// 락 획득
sem_acquire($mutex);
*/
// 파일에 잠금 걸기
return _Lock::LockFile();
}
public static function Unlock() {
// 파일에 잠금 풀기
$res = _Lock::UnlockFile();
/*
// 락 해제
sem_release($mutex);
*/
return $res;
}
}
?>
+48
View File
@@ -0,0 +1,48 @@
<?
require_once('_common.php');
require_once(ROOT.'/f_config/config.php');
require_once(ROOT.W.F_FUNC.W.'class._DB.php');
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
class _Log {
private static $flagLog = true;
public static function SetLog($type, $log) {
$filename = ROOT.W.D_LOG.W.$type."Log.txt";
if(_Log::$flagLog) AppendToFile($filename, $log."\r\n");
}
public static function GetWorldLog($type, $size=10) {
$filename = ROOT.W.D_LOG.W.$type."Log.txt";
if(_Log::$flagLog) {
$content = ReadToFileBackward($filename, $size*150);
$logs = explode("\r\n", $content);
$count = count($logs) - 1;
$start = $count - $size;
if($start < 0) $start = 0;
for($i = $start; $i < $count; $i++) {
$newLog[] = $logs[$i];
}
}
return $newLog;
}
public static function DecodeLog($log) {
$log = str_replace("<R>", "<font color=red>", $log);
$log = str_replace("<B>", "<font color=blue>", $log);
$log = str_replace("<G>", "<font color=green>", $log);
$log = str_replace("<M>", "<font color=magenta>", $log);
$log = str_replace("<C>", "<font color=cyan>", $log);
$log = str_replace("<L>", "<font color=limegreen>", $log);
$log = str_replace("<S>", "<font color=skyblue>", $log);
$log = str_replace("<O>", "<font color=orange>", $log);
$log = str_replace("<D>", "<font color=darkorange>", $log);
$log = str_replace("<Y>", "<font color=yellow>", $log);
$log = str_replace("<W>", "<font color=white>", $log);
$log = str_replace("</>", "</font>", $log);
return $log;
}
}
?>
+40
View File
@@ -0,0 +1,40 @@
<?
require_once('_common.php');
require_once(ROOT.W.E_LIB.W.'phpmailer5/class.phpmailer.php');
class _Mail {
private $objMail;
public function __construct($host, $port, $id, $pw, $addr) {
$this->objMail = new PHPMailer();
$this->objMail->IsSMTP();
$this->objMail->SMTPAuth = true;
$this->objMail->SMTPSecure = 'ssl';
$this->objMail->Host = $host;
$this->objMail->Port = $port;
$this->objMail->Username = $id;
$this->objMail->Password = $pw;
$this->objMail->ContentType = 'text/plain';
$this->objMail->CharSet = 'utf-8';
$this->objMail->Encoding = 'base64';
$this->objMail->SetFrom($addr);
}
public function Send($to, $subject, $content) {
$this->objMail->AddAddress($to);
$this->objMail->Subject = '=?utf-8?b?'.base64_encode($subject).'?=';
$this->objMail->Body = $content;
if(!$this->objMail->Send()) {
$result['msg'] = $this->objMail->ErrorInfo;
$result['result'] = 1;
} else {
$result['msg'] = 'Successfully sent.';
$result['result'] = 0;
}
return $result;
}
}
?>
+36
View File
@@ -0,0 +1,36 @@
<?
require_once('_common.php');
require_once(ROOT.'/f_config/config.php');
require_once(ROOT.W.F_FUNC.W.'class._Lock.php');
class _Process {
private static $mutexLog = false;
public static function ProcessingMutex($DB) {
// 어디선가 처리중이면 탈출
if(_Lock::Busy() == true) return false;
// 1명 외 접근 금지
if(_Lock::Lock() != true) return false;
_Process::MutexLog('뮤텍스 진입');
// 처리
_Process::Processing($DB);
_Process::MutexLog('뮤텍스 탈출');
// 접근 금지 해제
if(_Lock::UnLock() != true) return false;
return true;
}
private static function Processing($DB) {
}
private static function MutexLog($log) {
if(_Process::$mutexLog) _Log::SetLog('mutex', $log);
}
}
?>
+42
View File
@@ -0,0 +1,42 @@
<?
class _Queue {
private $capacity;
private $size;
private $head;
private $tail;
private $arr;
public function Queue($capacity) {
$this->capacity = $capacity;
$this->size = 0;
$this->head = 0;
$this->tail = 0;
}
public function getSize() {
return $this->size;
}
public function clear() {
$this->size = 0;
$this->head = 0;
$this->tail = 0;
}
public function push($value) {
if($this->size >= $this->capacity) return;
$this->arr[$this->tail] = $value;
$this->tail = ($this->tail + 1) % $this->capacity;
$this->size++;
}
public function pop() {
if($this->size <= 0) return null;
$value = $this->arr[$this->head];
$this->head = ($this->head + 1) % $this->capacity;
$this->size--;
return $value;
}
}
?>
+71
View File
@@ -0,0 +1,71 @@
<?
class _Session {
public function __construct() {
$sessionPath = ROOT.W.D_SESSION;
session_save_path($sessionPath);
session_cache_limiter('nocache, must_revalidate');
session_cache_expire(10080); // 60*24*7분
session_set_cookie_params(604800, '/');
// 세션 변수의 등록
session_start();
//첫 등장
if($_SESSION['ip'] == '') {
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
$_SESSION['time'] = time();
}
}
public static function TrashSession() {
$sessionPath = ROOT.W.D_SESSION;
if($dir = @opendir($sessionPath)) {
while($file = @readdir($dir)) {
if(!strstr($file, 'sess_')) continue;
if(strpos($file, 'sess_') != 0) continue;
if(!$atime = @fileatime("{$sessionPath}/{$file}")) continue;
if(time() > $atime+604800) { // 3600*24*7초
@unlink("{$sessionPath}/{$file}");
}
}
closedir($dir);
}
}
public function Set($key, $val) {
$_SESSION[$key] = $val;
}
public function Get($key) {
return $_SESSION[$key];
}
public function Login($noMember) {
$_SESSION['noMember'] = $noMember;
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
$_SESSION['time'] = time();
}
public function Logout() {
$_SESSION['noMember'] = 0;
session_destroy();
}
public function IsLoggedIn() {
if($_SESSION['noMember'] != 0) {
return true;
} else {
return false;
}
}
public function NoMember() {
return $_SESSION['noMember'];
}
public function __destruct() {
}
}
?>
+78
View File
@@ -0,0 +1,78 @@
<?
require_once('_common.php');
require_once(ROOT.'/f_config/config.php');
class _Setting {
private $settingFile;
private $isExist = 0;
private $dbHost;
private $dbId;
private $dbPw;
private $dbName;
private $mailHost;
private $mailPort;
private $mailId;
private $mailPw;
private $mailAddr;
public function __construct($filename) {
$this->settingFile = $filename;
if(file_exists($filename)) {
$this->isExist = 1;
$f = @file($filename);
$this->dbHost = trim(str_replace("\n", "", $f[1]));
$this->dbId = trim(str_replace("\n", "", $f[2]));
$this->dbPw = trim(str_replace("\n", "", $f[3]));
$this->dbName = trim(str_replace("\n", "", $f[4]));
$this->mailHost = trim(str_replace("\n", "", $f[5]));
$this->mailPort = trim(str_replace("\n", "", $f[6]));
$this->mailId = trim(str_replace("\n", "", $f[7]));
$this->mailPw = trim(str_replace("\n", "", $f[8]));
$this->mailAddr = trim(str_replace("\n", "", $f[9]));
}
}
public function IsExist() {
return $this->isExist;
}
public function DBHost() {
return $this->dbHost;
}
public function DBId() {
return $this->dbId;
}
public function DBPw() {
return $this->dbPw;
}
public function DBName() {
return $this->dbName;
}
public function MailHost() {
return $this->mailHost;
}
public function MailPort() {
return $this->mailPort;
}
public function MailId() {
return $this->mailId;
}
public function MailPw() {
return $this->mailPw;
}
public function MailAddr() {
return $this->mailAddr;
}
}
?>
+237
View File
@@ -0,0 +1,237 @@
<?
class _String {
public static function GetStrLen($str) {
$count = strlen($str);
$len = 0;
for($i=0; $i < $count; ) {
$code = ord($str[$i]);
if($code >= 0xf0) {
$len++;
$i += 4;
} elseif($code >= 0xe0) {
$len++;
$i += 3;
} elseif($code >= 0xc2) {
$len++;
$i += 2;
} else {
$len++;
$i += 1;
}
}
return $len;
}
public static function SubStr($str, $s, $l=1000) {
$count = strlen($str);
$startByte = 0; $isSet = 0;
$endByte = $count;
$len = 0;
for($i=0; $i < $count; ) {
$code = ord($str[$i]);
if($isSet == 0 && $len >= $s) {
$startByte = $i; $isSet = 1;
}
if($isSet == 1 && $len-$s >= $l) {
$endByte = $i;
break;
}
if($code >= 0xf0) {
$len++;
$i += 4;
} elseif($code >= 0xe0) {
$len++;
$i += 3;
} elseif($code >= 0xc2) {
$len++;
$i += 2;
} else {
$len++;
$i += 1;
}
}
$str = substr($str, $startByte, $endByte-$startByte);
return $str;
}
public static function SubStrForWidth($str, $s, $w) {
$count = strlen($str);
$startByte = 0; $isSet = 0;
$endByte = $count; $last = 0;
$len = 0;
$width = 0;
for($i=0; $i < $count; ) {
$code = ord($str[$i]);
if($isSet == 0 && $len >= $s) {
$startByte = $i; $isSet = 1;
$width = 0;
}
if($isSet == 1 && $width == $w) {
$endByte = $i;
break;
}
if($isSet == 1 && $width > $w) {
$endByte = $i - $last;
break;
}
if($code >= 0xf0) {
$len++;
$width += 2;
$last = 4;
$i += 4;
} elseif($code >= 0xe0) {
$len++;
$width += 2;
$last = 3;
$i += 3;
} elseif($code >= 0xc2) {
$len++;
$width += 2;
$last = 2;
$i += 2;
} else {
$len++;
$width += 1;
$last = 1;
$i += 1;
}
}
$str = substr($str, $startByte, $endByte-$startByte);
return $str;
}
public static function CutStrForWidth($str, $s, $w, $ch='..') {
$isCut = 0;
$count = strlen($str);
$startByte = 0; $isSet = 0;
$endByte = $count; $last = 0;
$len = 0;
$width = 0;
for($i=0; $i < $count; ) {
$code = ord($str[$i]);
if($isSet == 0 && $len >= $s) {
$startByte = $i; $isSet = 1;
$width = 0;
}
if($isSet == 1 && $width >= $w) {
$endByte = $i - $last;
$isCut = 1;
break;
}
if($code >= 0xf0) {
$len++;
$width += 2;
$last = 4;
$i += 4;
} elseif($code >= 0xe0) {
$len++;
$width += 2;
$last = 3;
$i += 3;
} elseif($code >= 0xc2) {
$len++;
$width += 2;
$last = 2;
$i += 2;
} else {
$len++;
$width += 1;
$last = 1;
$i += 1;
}
}
if($isCut != 0) {
$str = substr($str, $startByte, $endByte-$startByte) . $ch;
}
return $str;
}
function Fill($str, $maxsize, $ch) {
$size = strlen($str);
$count = ($maxsize - $size) / 2;
for($i=0; $i < $count; $i++) {
$string = $string.$ch;
}
$string = $string.$str;
for($i=0; $i < $count; $i++) {
$string = $string.$ch;
}
return $string;
}
function Fill2($str, $maxsize, $ch='0') {
$size = strlen($str);
$count = ($maxsize - $size);
for($i=0; $i < $count; $i++) {
$string = $string.$ch;
}
$string = $string.$str;
return $string;
}
public static function EscapeTag($str) {
$str = htmlspecialchars($str);
$str = str_replace("\r\n", "<br>", $str);
$str = str_replace("\n", "<br>", $str);
// return nl2br(htmlspecialchars($str));
// return htmlspecialchars($str);
return $str;
}
public static function NoSpecialCharacter($str) {
$str = str_replace(" ", "", $str);
$str = str_replace("\"", "", $str);
$str = str_replace("'", "", $str);
$str = str_replace("", "", $str);
$str = str_replace("", "", $str);
$str = str_replace("", "", $str);
$str = str_replace("\\", "", $str);
$str = str_replace("/", "", $str);
$str = str_replace("`", "", $str);
$str = str_replace("-", "", $str);
$str = str_replace("=", "", $str);
$str = str_replace("[", "", $str);
$str = str_replace("]", "", $str);
$str = str_replace(";", "", $str);
$str = str_replace(",", "", $str);
$str = str_replace(".", "", $str);
$str = str_replace("~", "", $str);
$str = str_replace("!", "", $str);
$str = str_replace("@", "", $str);
$str = str_replace("#", "", $str);
$str = str_replace("$", "", $str);
$str = str_replace("%", "", $str);
$str = str_replace("^", "", $str);
$str = str_replace("&", "", $str);
$str = str_replace("*", "", $str);
$str = str_replace("(", "", $str);
$str = str_replace(")", "", $str);
$str = str_replace("_", "", $str);
$str = str_replace("+", "", $str);
$str = str_replace("|", "", $str);
$str = str_replace("{", "", $str);
$str = str_replace("}", "", $str);
$str = str_replace(":", "", $str);
$str = str_replace("", "", $str);
$str = str_replace("<", "", $str);
$str = str_replace(">", "", $str);
$str = str_replace("?", "", $str);
$str = str_replace(" ", "", $str);
return $str;
}
}
?>
+47
View File
@@ -0,0 +1,47 @@
<?
class _Time {
public static function DateToday() {
return date('Y-m-d');
}
public static function DatetimeNow() {
return date('Y-m-d H:i:s');
}
public static function DatetimeFromNowMinute($minute) {
return date('Y-m-d H:i:s', strtotime("{$minute} minutes"));
}
public static function DatetimeFromNowSecond($second) {
return date('Y-m-d H:i:s', strtotime("{$second} seconds"));
}
public static function DatetimeFromMinute($date, $minute) {
return date('Y-m-d H:i:s', strtotime($date) + $minute*60);
}
public static function DatetimeFromSecond($date, $second) {
return date('Y-m-d H:i:s', strtotime($date) + $second);
}
public static function CutSecond($date) {
$date[17] = '0';
$date[18] = '0';
return $date;
}
public static function CutMinute($date) {
$date[14] = '0';
$date[15] = '0';
$date[17] = '0';
$date[18] = '0';
return $date;
}
public static function HourMinuteSecond($second) {
return date('H:i:s', strtotime('00:00:00') + $second);
}
}
?>
+114
View File
@@ -0,0 +1,114 @@
<?
require_once(ROOT.W.F_FUNC.W.'class._String.php');
class _Validation {
public static function CheckID($id) {
$len = strlen($id);
if($len < 4 || $len > 12) { return 1; }
for($i=0; $i < $len; $i++) {
$ch = $id[$i];
if(($ch < '0' || $ch > '9') && ($ch < 'a' || $ch > 'z')) {
return 2;
}
}
return 0;
}
public static function CheckPW($pw) {
$len = strlen($pw);
if($len < 4 || $len > 12) { return 1; }
for($i=0; $i < $len; $i++) {
$ch = $pw[$i];
if(($ch < '0' || $ch > '9') && ($ch < 'a' || $ch > 'z')) {
return 2;
}
}
return 0;
}
public static function CheckPID($pid1, $pid2) {
$len1 = strlen($pid1);
$len2 = strlen($pid2);
if($len1 != 6 || $len2 != 7) { return 1; }
for($i=0; $i < $len1; $i++) {
$ch = $pid1[$i];
if(($ch < '0' || $ch > '9')) {
return 2;
}
}
for($i=0; $i < $len2; $i++) {
$ch = $pid2[$i];
if(($ch < '0' || $ch > '9')) {
return 2;
}
}
$year = $pid1[0].$pid1[1];
$month = $pid1[2].$pid1[3];
$day = $pid1[4].$pid1[5];
$sex = $pid2[0];
if($year < 50) { return 3; }
if($month < 1 || $month > 12) { return 3; }
if($day < 1 || $day > 31) { return 3; }
if($sex < 1 || $sex > 2) { return 3; }
// 주민등록번호 체크
$chk = 0;
for($i=0; $i <= 5;$i++) {
$chk += ($i%8 + 2) * $pid1[$i];
}
for($i=6; $i <= 11;$i++) {
$chk += ($i%8 + 2) * $pid2[$i-6];
}
$chk = 11 - ($chk % 11);
$chk = $chk % 10;
if($chk != $pid2[6]) {
return 3;
}
return 0;
}
public static function CheckBirth($pid1, $pid2) {
$len1 = strlen($pid1);
$len2 = strlen($pid2);
if($len1 != 6 || $len2 != 1) { return 1; }
for($i=0; $i < $len1; $i++) {
$ch = $pid1[$i];
if(($ch < '0' || $ch > '9')) {
return 2;
}
}
for($i=0; $i < $len2; $i++) {
$ch = $pid2[$i];
if(($ch < '0' || $ch > '9')) {
return 2;
}
}
$year = $pid1[0].$pid1[1];
$month = $pid1[2].$pid1[3];
$day = $pid1[4].$pid1[5];
$sex = $pid2[0];
//if($year < 50) { return 3; }
if($month < 1 || $month > 12) { return 3; }
if($day < 1 || $day > 31) { return 3; }
if($sex < 1 || $sex > 2) { return 3; }
return 0;
}
public static function CheckName($name) {
// $len = strlen($name);
$len = _String::GetStrLen($name);
if(strchr($name, "<")) { return 1; }
if(strchr($name, ">")) { return 2; }
if($len < 1 || $len > 6) { return $len; }
return 0;
}
public static function CheckEmail($email) {
if(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email)) {
return 1;
} else {
return 0;
}
}
}
?>
+231
View File
@@ -0,0 +1,231 @@
function ClearContent(sel) {
$(sel).html("");
}
function Open(url) {
window.open(url);
}
function Replace(url) {
location.replace(url);
}
function ReplaceFrame(url) {
window.top.location.replace(url);
}
function ImportStyle(href) {
var CSS = document.createElement('link');
CSS.rel = 'stylesheet';
CSS.type = 'text/css';
CSS.media = 'screen';
CSS.href = href;
document.getElementsByTagName('head')[0].appendChild(CSS);
}
function ImportView(sel, url) {
var html = $.ajax({
url: url,
async: false
});
$(sel).append(html.responseText);
}
function ImportAction(sel, url) {
var tag = "<script type=\"text/javascript\" src=\"" + url + "\"></script>";
$(sel).append(tag);
}
function ImportAction(url) {
// 비동기라서 동기화된 함수로 변경
// 추후 cache: true, 로 변경
// $.getScript(url, function() { eval(initFunc); });
$.ajax({
type: 'GET',
url: url,
cache: true,
async: false,
dataType: 'script'
});
}
function GetJSON(url, data, callback) {
$.ajax({
type: 'GET',
url: url,
cache: true,
async: true,
data: data,
success: callback,
dataType: 'json',
error: Error
});
}
function GetJSONSync(url, data, callback) {
$.ajax({
type: 'GET',
url: url,
cache: true,
async: false,
data: data,
success: callback,
dataType: 'json',
error: Error
});
}
function PostJSON(url, data, callback) {
$.ajax({
type: 'POST',
url: url,
cache: true,
async: true,
data: data,
success: callback,
dataType: 'json',
error: Error
});
}
function PostJSONSync(url, data, callback) {
$.ajax({
type: 'POST',
url: url,
cache: true,
async: false,
data: data,
success: callback,
dataType: 'json',
error: Error
});
}
function Error(xhr, textStatus, errorThrown) {
// alert(xhr.status);
alert(xhr.responseText);
// alert(textStatus);
// alert(errorThrown);
/*
if(xhr.status == 404) {
alert("처리 프로그램이 없습니다!");
alert(xhr.responseText);
} else if(xhr.status == 500) {
alert("처리 프로그램이 오류입니다!");
alert(xhr.responseText);
}
*/
}
function IsNumber(input) {
var check = /(^\d+$)/;
return check.test(input);
}
function Second(time, amount) {
var h = parseInt(time.substr(0, 2), 10);
var m = parseInt(time.substr(3, 2), 10);
var s = parseInt(time.substr(6, 2), 10);
s += amount;
if(amount > 0) {
if(s > 60) { m += Math.floor(s/60); s = s%60; }
if(m > 60) { h += Math.floor(m/60); m = m%60; }
if(h > 24) { h = h%24; }
} else {
if(s < 0) { m += Math.floor(s/60); s = 60+s%60; }
if(m < 0) { h += Math.floor(m/60); m = 60+m%60; }
if(h < 0) { h = 24+h%24; }
}
if(h < 10) h = "0"+h;
if(m < 10) m = "0"+m;
if(s < 10) s = "0"+s;
var newTime = h+":"+m+":"+s;
return newTime;
}
function ExitButton(obj) {
$(obj).each(function() {
$(this).css("background", "transparent url(../e_image/button/exit0x26x25.png) no-repeat");
$(this).mouseover(function () { $(this).css("background", "transparent url(../e_image/button/exit1x26x25.png) no-repeat" ); });
$(this).mouseout(function () { $(this).css("background", "transparent url(../e_image/button/exit0x26x25.png) no-repeat"); });
$(this).mousedown(function () { $(this).css("background", "transparent url(../e_image/button/exit2x26x25.png) no-repeat"); });
$(this).mouseup(function () { $(this).css("background", "transparent url(../e_image/button/exit1x26x25.png) no-repeat"); });
});
}
function Button(obj, w) {
$(obj).each(function() {
$(this).css("background", "transparent url(../e_image/button/button0x"+w+"x20.png) no-repeat");
$(this).mouseover(function () { $(this).css("background", "transparent url(../e_image/button/button1x"+w+"x20.png) no-repeat" ); });
$(this).mouseout(function () { $(this).css("background", "transparent url(../e_image/button/button0x"+w+"x20.png) no-repeat"); });
$(this).mousedown(function () { $(this).css("background", "transparent url(../e_image/button/button2x"+w+"x20.png) no-repeat"); });
$(this).mouseup(function () { $(this).css("background", "transparent url(../e_image/button/button1x"+w+"x20.png) no-repeat"); });
});
}
function Disable(obj, w) {
$(obj).each(function() {
$(this).css("background", "transparent url(../e_image/button/button3x"+w+"x20.png) no-repeat");
$(this).css("color", "#CCCCCC");
$(this).css("font-style", "italic");
$(this).css("cursor", "default");
$(this).attr("disabled", "true");
});
}
function Enable(obj, w) {
$(obj).each(function() {
$(this).css("background", "transparent url(../e_image/button/button0x"+w+"x20.png) no-repeat");
$(this).css("color", "#FFFFFF");
$(this).css("font-style", "normal");
$(this).css("cursor", "pointer");
$(this).attr("disabled", "");
});
}
function Drag(obj) {
var _ox = $(obj).offset().left;
var _oy = $(obj).offset().top;
$(obj).attr("_x", 0);
$(obj).attr("_y", 0);
$(obj).attr("_ox", _ox);
$(obj).attr("_oy", _oy);
$(obj).bind("dragstart", function(event) {
$(this).attr("_x", $(this).scrollLeft());
$(this).attr("_y", $(this).scrollTop());
});
$(obj).bind("dragend", function(event) {
$(this).attr("_x", $(this).scrollLeft());
$(this).attr("_y", $(this).scrollTop());
});
$(obj).bind("drag", function(event) {
var _x = parseInt($(this).attr("_x"));
var _y = parseInt($(this).attr("_y"));
var _ox = parseInt($(this).attr("_ox"));
var _oy = parseInt($(this).attr("_oy"));
$(this).scrollLeft(_x + _ox - event.offsetX);
$(this).scrollTop(_y + _oy - event.offsetY);
});
}
function ScrollTo(obj, x, y) {
var w = $(obj).width();
var h = $(obj).height();
$(obj).scrollLeft(x - w/2);
$(obj).scrollTop(y - h/2);
}
function CheckIE6PNG() {
if($.browser.msie == true && $.browser.version == "6.0") {
DD_belatedPNG.fix(".png");
}
}
+100
View File
@@ -0,0 +1,100 @@
<?
function CustomHeader() {
if(!headers_sent()) {
header('Cache-Control: no-cache');
header('Pragma: no-cache');
// header('Cache-Control: public');
// header('Pragma: public');
header('Content-Type: text/html; charset=utf-8');
}
//define(CURPATH, 'f_async');
//define(FILE, substr(strrchr(__FILE__, "\\"), 1));
}
function getmicrotime() {
$microtimestmp = explode(' ', microtime());
return $microtimestmp[0] + $microtimestmp[1];
}
function Error($msg) {
AppendToFile(ROOT.'/d_log/err.txt', $msg."\r\n");
exit(1);
}
function ErrorToScreen($msg) {
AppendToFile(ROOT.'/d_log/err.txt', $msg."\r\n");
echo $msg;
exit(1);
}
function WriteToFile($filename, $content) {
$fp = @fopen($filename, 'w');
@fwrite($fp, $content);
@fclose($fp);
}
function AppendToFile($filename, $content) {
$fp = @fopen($filename, 'a');
@fwrite($fp, $content);
@fclose($fp);
}
function ReadToFile($filename) {
$fp = @fopen($filename, 'r');
$content = @fread($fp, filesize($filename));
@fclose($fp);
return $content;
}
function ReadToFileForward($filename, $size) {
$fp = @fopen($filename, 'r');
$content = @fread($fp, $size);
@fclose($fp);
return $content;
}
function ReadToFileBackward($filename, $size) {
$fp = @fopen($filename, 'r');
@fseek($fp, -$size, SEEK_END);
$content = @fread($fp, $size);
@fclose($fp);
return $content;
}
function delInDir($dir) {
$handle = opendir($dir);
while(false !== ($FolderOrFile = readdir($handle))) {
if($FolderOrFile != "." && $FolderOrFile != "..") {
if(is_dir("$dir/$FolderOrFile")) {
delInDir("$dir/$FolderOrFile");
} // recursive
else {
unlink("$dir/$FolderOrFile");
}
}
}
closedir($handle);
return $success;
}
function delExpiredInDir($dir, $t) {
$handle = opendir($dir);
while(false !== ($FolderOrFile = readdir($handle))) {
if($FolderOrFile != "." && $FolderOrFile != "..") {
if(is_dir("$dir/$FolderOrFile")) {
delExpiredInDir("$dir/$FolderOrFile", $t);
} // recursive
else {
$mt = filemtime("$dir/$FolderOrFile");
if($mt < $t) {
unlink("$dir/$FolderOrFile");
}
}
}
}
closedir($handle);
return $success;
}
?>