ApiBase.php 14 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
<? include_once $_SERVER["DOCUMENT_ROOT"] . "/common/classes/comm/Common.php" ; ?>
<?php
if(! class_exists("ApiBase") )	{

	class ApiBase extends Common {
		
		
		// xml 키가 들어 왔을경우 
		function __construct($req) 
		{
			parent::__construct($req);
		}

		function wrapParam()
		{
			$this->req['page']	= ($this->req['page'] == "") ? 1 : $this->req['page'] ;			 
		}
				
		function getAddQuery()
		{			
			$addQuery = "" ;

			return $addQuery ;
		}

		
		
		
		/***************************************************************************
		*	제  목 : 인트로 프로세스
		*	함수명 : introProcess
		*	작성일 : 2013-08-19
		*	작성자 : dev.Na
		*	설  명 : 
		*	수  정 :
		'***************************************************************************/
		function introProcess()
		{
			$appVersion			= $this->req["appVersion"];
			$deviceID			= $this->req["deviceID"];
			$deviceTypeID		= $this->req["deviceTypeID"];
			$storeTypeID		= $this->req["storeTypeID"];
			$registrationKey	= $this->req["registrationKey"];
			$userNumber			= $this->req["no"];
			$app_type			= $this->req["app_type"];
			
			
			

			$versionParams["appVersion"]	= $appVersion;			// APP 버전
			$versionParams["deviceTypeID"]	= $deviceTypeID;		// APP 타입
			$versionParams["storeTypeID"]	= $storeTypeID;		// store 타입
			$versionParams["userNumber"]	= $userNumber;
			$versionParams["appType"]		= $app_type;		// 1:동네 2:직장
			
			$versionInfo = $this->inFn_ApiBase_getVersionSync($versionParams);


			$loginParams["userNumber"]			= $userNumber;
			$loginParams["deviceID"]			= $deviceID;
			$loginParams["deviceTypeID"]		= $deviceTypeID;
			$loginParams["storeTypeID"]			= $storeTypeID;
			$loginParams["registrationKey"]		= $registrationKey;
			$loginParams["appVersion"]			= $appVersion;
			$loginParams["appType"]				= $app_type;

			$loginInfo = $this->inFn_ApiBase_autoLogin($loginParams);
			
			$openPopupInfo = $this->inFn_ApiBase_popupInfo($this->POPUP_TYPE_OPEN);
			$closePopupInfo = $this->inFn_ApiBase_popupInfo($this->POPUP_TYPE_CLOSE);
			
			$entity = Array(
				"version"	=> $versionInfo["version"],
				"marketUrl"	=> $versionInfo["marketUrl"]
			);
			
			
			
			$addData = Array(
				"loginData"	=> $loginInfo,
				"openPopupInfo" => $openPopupInfo,
				"closePopupInfo" => $closePopupInfo
			);
			
			return $this->makeResultJson($versionInfo["returnCode"], $versionInfo["returnMessage"], $entity, $addData);

		}



		function doAppLogout()
		{
			LoginUtil::doAppLogout();

			$resultJson = Array(
				"callApi"		=> $this->callApi,
				"returnCode"	=> "1",
				"returnMessage"	=> "로그아웃 처리되었습니다.",
				"entity"		=> ""
			);

			return json_encode($resultJson);
		}

		
		/***************************************************************************
		*	제  목 : 이용약관/개인정보 취급방침
		*	함수명 : getInfoOfProvision
		*	작성일 : 2013-08-19
		*	작성자 : dev.Na
		*	설  명 : 
		*	수  정 :
		'***************************************************************************/
		function getInfoOfProvision()
		{
			$agreeTypeID = $this->req["agreeTypeID"];
			$agreeTypeID = 2;
			
			$agree = "";

			if($agreeTypeID == "1")
			{
				$filePath = $this->agreeInfoPath;
			}
			else
			{
				$filePath = $this->privacyInfoPath;
			}

			$files = fopen($filePath, "r");
			
			while($ss = fgets($files, 1024))	
			{
				$agree .= $ss;
			}
			
			fclose($files);

			$resultJson = array(
				"returnCode"	=> "1" ,
				"returnMessage" => "" ,
				"entity"		=> $agree
			) ;

			return json_encode($resultJson) ;
		}
		
		function getPrivacyInfo(){
			$filePath = $this->privacyInfoPath;
			$files = fopen($filePath, "r");
				
			while($ss = fgets($files, 1024))
			{
				$agree .= $ss;
			}
				
			fclose($files);
			
			$resultJson = array(
					"returnCode"	=> "1" ,
					"returnMessage" => "" ,
					"entity"		=> $agree
			) ;
			
			return json_encode($resultJson) ;
		}
		
		function getAgreeInfo(){
			$filePath = $this->agreeInfoPath;
			$files = fopen($filePath, "r");
				
			while($ss = fgets($files, 1024))
			{
				$agree .= $ss;
			}
				
			fclose($files);
			
			$resultJson = array(
					"returnCode"	=> "1" ,
					"returnMessage" => "" ,
					"entity"		=> $agree
			) ;
			
			return json_encode($resultJson) ;
		}
		
		
		/***************************************************************************
		 *	제  목 : 팝업 정보 조회
		 *	함수명 : inFn_ApiBase_popupInfo
		 *	작성일 : 2013-08-19
		 *	작성자 : dev.Na
		 *	설  명 :
		 *	수  정 :
		 '***************************************************************************/
		function inFn_ApiBase_popupInfo($popup_type)
		{
			$sql = "
				SELECT *
				FROM tbl_popup
				WHERE popup_type = '{$popup_type}' AND is_apply = 1 AND status = 'Y'
				LIMIT 1
			";
			$result = $this->getRow($sql);
			
			return $result;
			
		}



		/***************************************************************************
		*	제  목 : 자동 로그인 함수
		*	함수명 : inFn_ApiBase_autoLogin
		*	작성일 : 2013-08-19
		*	작성자 : dev.Na
		*	설  명 : 
		*	수  정 :
		'***************************************************************************/
		function inFn_ApiBase_autoLogin($loginParams)
		{

			$param = Array(
				$loginParams[0],
				$loginParams[1],
				$loginParams[2],
				$loginParams[3],
				$loginParams[4]
			) ;
			
			$ret = Array(
				"po_returnCode"	=>	"@po_returnCode",
				"po_returnMsg"	=>	"@po_returnMsg"
			) ; 
			
			$sql = $this->strCallProc("uspU_autoLogin", $param, $ret) ;
			

			$result =  $this->getMultiArray($sql) ;

			//echo $loginParams[5];
			
			if($result[0][0]["po_returnCode"] == "-1")
			{
				$loginInfo["isLogin"]		= $result[0][0]["po_returnCode"];
				$loginInfo["loginMessage"]	= $result[0][0]["po_returnMsg"];
				$loginInfo["loginInfo"]	= "";
			}
			else
			{
				$loginInfo["isLogin"]		= $result[0][0]["po_returnCode"];
				$loginInfo["loginMessage"]	= $result[0][0]["po_returnMsg"];
				$loginInfo["loginInfo"]	= $this->inFn_ApiBase_getInfoOfUser($loginParams[0]);
				/*
				if($loginParams[5]!=$loginInfo["loginInfo"]["userPwd"]){
					$loginInfo["loginInfo"]="";
					$loginInfo["isLogin"]="-1000";
					$loginInfo["loginMessage"]="비밀번호를 확인하세요";
					return $loginInfo;
				}
				*/
					
				LoginUtil::doAppLogin($loginInfo["loginInfo"]);
			}
			
			return $loginInfo;
		}




		/***************************************************************************
		*	제  목 : 회원정보 조회
		*	함수명 : inFn_ApiBase_getInfoOfUser
		*	작성일 : 2013-08-20
		*	작성자 : dev.Na
		*	설  명 : 
		*	수  정 :
		'***************************************************************************/
		function inFn_ApiBase_getInfoOfUser($userNo)
		{
			$sql = "
				SELECT 
					U.*
				FROM tblUser U
				WHERE U.userNo = '{$userNo}' AND status=1
				LIMIT 0, 1
			";

			$userInfo = $this->getRow($sql);

			if($userInfo == null)
			{
				return false;
			}
			else
			{
				//unset($userInfo["userPwd"])	;
			}

			return $userInfo;
		}



		/***************************************************************************
		*	제  목 : 버전체크 내부함수
		*	함수명 : inFn_ApiBase_getVersionSync
		*	작성일 : 2013-07-04
		*	작성자 : dev.Na
		*	설  명 : 
		*	수  정 :
		'***************************************************************************/
		function inFn_ApiBase_getVersionSync($versionParams)
		{			
			$appVersion		= $versionParams["appVersion"];			// APP 버전
			$appTypeID		= $versionParams["deviceTypeID"];		// APP 타입

			$appVersionInt = (int)str_replace(".", "", $appVersion);
			
			$isMustUpdate = "0";
			
			$sql = "
				SELECT COUNT(*) AS isUpdate
				FROM tblAppVersion 
				WHERE appTypeID = '{$appTypeID}' AND versionInt > {$appVersionInt};
				
				SELECT COUNT(*) AS isMustUpdate
				FROM tblAppVersion 
				WHERE appTypeID = '{$appTypeID}' versionInt > {$appVersionInt} AND isMustUpdate > 0;
				
				SELECT version
				FROM tblAppVersion
				WHERE appTypeID = '{$appTypeID}' 
				ORDER BY versionInt DESC
				LIMIT 0, 1;
			";
			
			
			$result = $this->getMultiArray($sql);

			

			if($result[2][0]["version"] == "")
			{
				$returnCode = "-1";
				$returnMessage = "해당 마켓에 등록된 어플이 아닙니다.";
			}
			else if($result[0][0]["isUpdate"] > 0)
			{
				$returnCode = "-10";
				$returnMessage = "업데이트된 버전이 있습니다. 업데이트 받으시겠습니까?";
				
				if($result[1][0]["isMustUpdate"] > 0)
				{
					$returnCode = "-20";
					$returnMessage = "업데이트된 버전이 있습니다. 업데이트 받으셔야만 이용하실 수 있습니다.";
				}	
			}
			else
			{
				$returnCode = "1";
				$returnMessage = "";
			}

			$marketUrl = "";

			
			$retArr = Array(
				"returnCode"	=> $returnCode,
				"returnMessage"	=> $returnMessage,
				"version"		=> $result[2][0]["version"],
				"marketUrl"		=> $marketUrl,
			);

			return $retArr;
		}


		/***************************************************************************
		*	제  목 : 다중 파일 업로드
		*	함수명 : fileUpload
		*	작성일 : 2013-07-22
		*	작성자 : dev.Na
		*	설  명 : 
		*	수  정 :
		'***************************************************************************/
		function fileUploadMulti()
		{

			$Extension = array("txt","html","asp","php");
			$Upload = new UploadUtil($_FILES["file"],$this->fileSavePath,$Extension,1);
			$fileData = $Upload->processing() ;

			$fileList = Array() ;

			
			for( $i = 0 ; $i < sizeof($_FILES["file"]["name"]) ; $i++ )
			{
				if( strcmp($fileData[$i]['re_name'],"") ){
					$fileName = $Upload->GetDate() . "/" . $fileData[$i]['re_name'];
					array_push($fileList, $fileName);
					$image = new SimpleImage();
					$assoc = array($this->fileSavePath_720, $this->fileSavePath_640, $this->fileSavePath_480, $this->fileSavePath_320, $this->fileSavePath_100) ; 
					$image->check($assoc) ;
					$image->processing($this->fileSavePath . $Upload->GetDate() . "/", $this->fileSavePath_720, 720, $fileData[$i]['re_name']) ;
					$image->processing($this->fileSavePath . $Upload->GetDate() . "/", $this->fileSavePath_640, 640, $fileData[$i]['re_name']) ;
					$image->processing($this->fileSavePath . $Upload->GetDate() . "/", $this->fileSavePath_480, 480, $fileData[$i]['re_name']) ;
					$image->processing($this->fileSavePath . $Upload->GetDate() . "/", $this->fileSavePath_320, 320, $fileData[$i]['re_name']) ;
					$image->processing($this->fileSavePath . $Upload->GetDate() . "/", $this->fileSavePath_100, 100, $fileData[$i]['re_name']) ;
				}
			}

			if(sizeof($fileList) > 0)
			{
				$resultJson = Array(
					"callApi"			=> $this->callApi,
					"returnCode"		=> "1",
					"returnMessage"		=> "",
					"entity"			=> $fileList
				);
				
				return json_encode($resultJson);
			}

			
		}


		/***************************************************************************
		*	제  목 : 파일 업로드
		*	함수명 : fileUpload
		*	작성일 : 2013-07-22
		*	작성자 : dev.Na
		*	설  명 : 
		*	수  정 :
		'***************************************************************************/
		function fileUpload()
		{

			$Extension = array("txt","html","asp","php");
			$Upload = new UploadUtil($_FILES["file"],$this->fileSavePath,$Extension,1);
			$fileData = $Upload->processing() ;

			$filePath = "" ;
			
			if( strcmp($fileData[0]['re_name'],"") ){
				$filePath = $Upload->GetDate() . "/" . $fileData[0]['re_name'];
				$image = new SimpleImage();
				$assoc = array($this->fileSavePath_720, $this->fileSavePath_640, $this->fileSavePath_480, $this->fileSavePath_320, $this->fileSavePath_100) ; 

				$image->check($assoc) ;

				$image->processing($this->fileSavePath . $Upload->GetDate() . "/", $this->fileSavePath_720, 720, $fileData[0]['re_name']) ;
				$image->processing($this->fileSavePath . $Upload->GetDate() . "/", $this->fileSavePath_640, 640, $fileData[0]['re_name']) ;
				$image->processing($this->fileSavePath . $Upload->GetDate() . "/", $this->fileSavePath_480, 480, $fileData[0]['re_name']) ;
				$image->processing($this->fileSavePath . $Upload->GetDate() . "/", $this->fileSavePath_320, 320, $fileData[0]['re_name']) ;
				$image->processing($this->fileSavePath . $Upload->GetDate() . "/", $this->fileSavePath_100, 100, $fileData[0]['re_name']) ;
			}
			

			if($filePath == "")
			{
				$returnCode		= "-1";
				$returnMessage	= "";
			}
			else
			{
				$returnCode		= "1";
				$returnMessage	= "";	
			}


			$resultJson = Array(
				"callApi"			=> $this->callApi,
				"returnCode"		=> $returnCode,
				"returnMessage"		=> $returnMessage,
				"entity"			=> $filePath
			);
			
			return json_encode($resultJson);

		}



		/***************************************************************************
			*	제  목 : 이미지 파일 사이즈 구하기
		*	함수명 : fileUpload
		*	작성일 : 2013-07-22
		*	작성자 : dev.Na
		*	설  명 : 
		*	수  정 :
		'***************************************************************************/
		function getImageSize($imgUrl)
		{
			$imgUrl = str_replace("/upload_img/", "", $imgUrl);

			$imgUrl = $this->fileSavePath.$imgUrl;
			$sizeInfo = getimagesize($imgUrl);

			if($sizeInfo != false)
			{
				$file_width		= $sizeInfo[0];
				$file_height	= $sizeInfo[1];
			}
			else
			{
				$file_width		= "0";
				$file_height	= "0";
			}

			$retArr = Array(
				"file_name"		=> str_replace($this->fileSavePath, "", $imgUrl),
				"file_width"	=> $file_width,
				"file_height"	=> $file_height
			);

			return $retArr;

		}



		// 파일명중 확장자를 분리해준다.
		function getFileExtension($imgUrl){
			
			$Tmp = explode(".",$imgUrl);
			
			return $Tmp[count($Tmp)-1];
		}


		function smsTest()
		{
			$str = "투리 테스트입니다. 님의 선물을 받아주세요.퍼니룰렛 돌리고, 퍼니콘 직접 고르기!돌리러 가기 http://funnycon.richware.co.kr/appStart.php" ;
			$this->sendSMS($str, "010-4220-1597", $this->turiCSPhone) ;

			// http://funnycon.richware.co.kr/action_front.php?cmd=ApiBase.smsTest
		}
		

		/**
		 * 댓글 삭제
		 * @param $commentNo
		 */
		function inFn_ApiBase_delComment($commentNo)
		{
			$sql = "
				DELETE FROM tbl_comment WHERE `no` = '{$commentNo}'
			";
			$this->update($sql);
		}
		
	}//클래스 종료
}
?>