This commit is contained in:
shim
2023-04-17 11:06:08 +09:00
parent d0b393aa97
commit 76264e09ad
4686 changed files with 552713 additions and 0 deletions

View File

View File

@@ -0,0 +1,160 @@
<?php
// Rb DB 객체화
Class comment_DB{
public $changeQue;
public function query($sql){
global $DB_CONNECT;
$change_result=$this->changeQue=db_query($sql,$DB_CONNECT);
return $change_result;
}
public function fetch_assoc($result){
$change_result=$this->changeQue=db_fetch_assoc($result);
return $change_result;
}
public function fetch_array($result){
$change_result=$this->changeQue=db_fetch_array($result);
return $change_result;
}
public function num_rows($result){
$change_result=$this->changeQue=db_num_rows($result);
return $change_result;
}
// 문자열 escape
public function real_escape_string($string){
global $DB_CONNECT;
return mysqli_real_escape_string($DB_CONNECT,$string);
}
}
// 모듈 기본환경 설정
class Member_base {
public $module;
public function __construct() {
global $g,$table;
$this->module = 'member';
}
// 테이블명 추출
public function table($lastname){
global $table;
return $table[$this->module.$lastname];
}
// mobile 여부 값 추출
public function is_mobile(){
global $g;
if($g['mobile']&&$_SESSION['pcmode']!='Y') return true;
else return false;
}
// device 정보 추출
public function getUserAgent(){
$device = '';
$result = array();
if( stristr($_SERVER['HTTP_USER_AGENT'],'ipad') ) {
$device = "ipad";
} else if( stristr($_SERVER['HTTP_USER_AGENT'],'iphone') || strstr($_SERVER['HTTP_USER_AGENT'],'iphone') ) {
$device = "iphone";
} else if( stristr($_SERVER['HTTP_USER_AGENT'],'blackberry') ) {
$device = "blackberry";
} else if( stristr($_SERVER['HTTP_USER_AGENT'],'android') ) {
$device = "android";
}
if( $device ) {
return $device;
} return false; {
return false;
}
}
public function getAssoc($query){
$rows=array();
$result=$this->db->query($query);
while ($row=$this->db->fetch_assoc($result)) $rows[]=$row;
return $rows;
}
public function getArray($query){
$rows=array();
$result=$this->db->query($query);
while ($row=$this->db->fetch_array($result)) $rows[]=$row;
return $rows;
}
public function getRows($query){
$result=$this->db->query($query);
$rows=$this->db->num_rows($result);
return $rows;
}
// uid 기준 row 데이타 추출
public function getUidData($table,$uid){
$query= sprintf("SELECT * FROM `%s` WHERE `uid` = %s",$table,$this->db->real_escape_string($uid));
$rows = $this->getArray($query);
return $rows[0];
}
// 숫자 변경 함수
public function formatWithSuffix($input)
{
$suffixes = array('', 'K', 'M', 'G', 'T');
$suffixIndex = 0;
while(abs($input) >= 1000 && $suffixIndex < sizeof($suffixes))
{
$suffixIndex++;
$input /= 1000;
}
return (
$input > 0
// precision of 3 decimal places
? floor($input * 1000) / 1000
: ceil($input * 1000) / 1000
)
. $suffixes[$suffixIndex];
}
// 사용자 입력내용 중 해시태그 분리 함수
public function gethashtags($text)
{
//Match the hashtags
preg_match_all('/(^|[^0-9a-zA-Z가-힣_])#([0-9a-zA-Z가-힣]+)/i', $text, $matchedHashtags);
$hashtag = '';
// For each hashtag, strip all characters but alpha numeric
if(!empty($matchedHashtags[0])) {
foreach($matchedHashtags[0] as $match) {
$hashtag .= preg_replace("/[^0-9a-zA-Z가-힣]+/i", "", $match).',';
}
}
//to remove last comma in a string
return rtrim($hashtag, ',');
}
// 해시태그 분리하여 링크 추가 함수
public function addLink_hashtag($message)
{
global $g;
$parsedMessage = preg_replace(array('/(?i)\b((?:https?:\/\/|www\d{0,3}[.]|[0-9a-zA-Z가-힣.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))/', '/(^|[^0-9a-zA-Z가-힣_])@([0-9a-zA-Z가-힣_]+)/i', '/(^|[^0-9a-zA-Z가-힣_])#([0-9a-zA-Z가-힣_]+)/i'), array('<a href="$1" target="_blank">$1</a>', '$1<a href="">@$2</a>', '$1<a class="hash-alink" href="'.$g['s'].'/?m=sns&mod=search&tag=$2">#$2</a>'), $message);
return $parsedMessage;
}
}
?>

View File

@@ -0,0 +1,43 @@
<?php
class Member extends Member_base{
public $parent;
public $parent_table;
public $theme_name;
public $recnum; // 출력 기본 값
public $sort;
public $orderby;
public $oneline_recnum = 5;
// 테마 패스 추출함수
public function getThemePath($type){
global $g;
if($type=='relative') $result = $g['path_module'].$this->module.'/themes/'.$this->theme_name;
else if($type=='absolute') $result = $g['url_root'].'/modules/'.$this->module.'/themes/'.$this->theme_name;
return $result;
}
// get html & replace-parse
public function getHtml($fileName) {
global $g,$TMPL;
$theme_path = $this->getThemePath('relative');
$file = sprintf($theme_path.'/_html/%s.html', $fileName);
$fh_skin = fopen($file, 'r');
$skin = @fread($fh_skin, filesize($file));
fclose($fh_skin);
//return $skin;
return $this->getParseHtml($skin);
}
public function getParseHtml($skin) {
global $TMPL;
// $skin = preg_replace_callback('/{\$lng->(.+?)}/i', create_function('$matches', 'global $LNG; return $LNG[$matches[1]];'), $skin);
$skin = preg_replace_callback('/{\$([a-zA-Z0-9_]+)}/', create_function('$matches', 'global $TMPL; return (isset($TMPL[$matches[1]])?$TMPL[$matches[1]]:"");'), $skin);
return $skin;
}
}
?>