Example #1
0
// 필요한 데이터 저장
$nowTime = time();
$lastTime = $datarow["loginTime"];
$nowHearts = $datarow["hearts"];
if ($nowHearts < 5) {
    $spendTime = $nowTime - $lastTime;
    if ($spendTime >= 595 && $spendTime <= 599) {
        $spendTime = 600;
    }
    $totalHearts = $nowHearts + floor($spendTime / 600);
    if ($totalHearts > 5) {
        $totalHearts = 5;
    }
    if ($totalHearts != $nowHearts) {
        $sqlUpdateHearts = "UPDATE `usercore`\n            SET `hearts` = '" . $totalHearts . "', `loginTime` = '" . $nowTime . "'\n            WHERE `no` = " . $userKeyNo;
        $resultUpdateHearts = SendSqlQuery($sqlUpdateHearts, "UpdateHearts", $mysqli);
        $lastTime = $nowTime;
        $nowHearts = $totalHearts;
    }
}
//server time //lastTime //heart 보낸다.
// 사용자 데이터가 존재하므로 리턴할 XML 데이터 구조 생성
$dom = new DOMDocument('1.0', 'UTF-8');
//root 노드 생성
$rootNode = $dom->createElement('farmdefence');
$dom->appendChild($rootNode);
$response = $dom->createElement("result");
$rootNode->appendChild($response);
$serverTime = nodeMaker($dom, "serverTime", $nowTime);
$loginTime = nodeMaker($dom, "loginTime", $lastTime);
$hearts = nodeMaker($dom, "hearts", $nowHearts);
Example #2
0
$mysqli = new mysqli($host, $user, $password, $dbname);
if (mysqli_connect_errno()) {
    echo 'Connect faild : ' . mysqli_connect_error() . '\\n';
    $mysqli->close();
    exit;
}
// utf8로 charset 변경
$mysqli->set_charset("utf8");
// 중복 아이디가 있는지 찾아보는 쿼리문
$findUserID = "SELECT * FROM `usercore` WHERE `id` = '" . $userID . "' AND `facebook` = '" . $fbID . "'";
// 쿼리 실행
$resultFindUserID = SendSqlQuery($findUserID, "findUserID", $mysqli);
// 예외처리 : 중복 아이디가 발견된 경우
if ($resultFindUserID->num_rows > 0) {
    $datarow = mysqli_fetch_array($resultFindUserID);
    echo "exist" . $datarow["no"];
    $mysqli->close();
    exit;
}
// 새로운 아이디를 넣은 행을  usercore 테이블 생성하는 쿼리문
$insertUserID = "INSERT INTO `usercore`\n    (`no`, `id`, `gems`, `coins`, `hearts`, `highScore`, `loginTime`, `facebook`)\n    VALUES\n    (null, '" . $userID . "', 20, 1000, 5, 0, " . time() . ", '" . $fbID . "')";
$resultInsertUserID = SendSqlQuery($insertUserID, "insertUserID", $mysqli);
$saveInsertId = $mysqli->insert_id;
// 사용자 업그레이드 할당하는 쿼리문
$insertUpgrade = "INSERT INTO `userupgrade`\n    (`no`, `user`)\n    VALUES\n    (null, '" . $saveInsertId . "')";
$resultInsertUpgrade = SendSqlQuery($insertUpgrade, "insertUpgrade", $mysqli);
// 행 번호를 결과로 리턴.
echo "done0" . $saveInsertId;
// 데이터베이스 접속을 종료.
$mysqli->close();
exit;
Example #3
0
include "dbHelper.php";
//
$userKeyNo = $_REQUEST["userKeyNo"];
//
$mysqli = new mysqli($host, $user, $password, $dbname);
if (mysqli_connect_errno()) {
    echo 'Connect faild : ' . mysqli_connect_error() . '\\n';
    $mysqli->close();
    exit;
}
//
$mysqli->set_charset("utf8");
//
$sqlFindInappItem = "SELECT * FROM `inappitem` ORDER BY `no`";
//
$resultInappItem = SendSqlQuery($sqlFindInappItem, "InappItem", $mysqli);
//
$dom = new DOMDocument('1.0', 'UTF-8');
//root element
$rootNode = $dom->createElement('farmdefence');
$dom->appendChild($rootNode);
$response = $dom->createElement("inapp");
$rootNode->appendChild($response);
//db php
while ($datarow = mysqli_fetch_array($resultInappItem)) {
    $dataNode = $dom->createElement('InappItemData');
    $no = nodeMaker($dom, "no", $datarow["no"]);
    $codeNo = nodeMaker($dom, "codeNo", $datarow["codeNo"]);
    $sku = nodeMaker($dom, "sku", $datarow["sku"]);
    $dataNode->appendChild($no);
    $dataNode->appendChild($codeNo);
Example #4
0
        $resultResurrectionUse = 0;
    }
    $sqlUpdateRessurrection = "UPDATE `useritem` SET `use` = " . $resultResurrectionUse . ", `amount` = " . $resultResurrectionCount . " WHERE `no` = " . $dataFindRessurrection["no"];
    $resultUpdateRessurrection = SendSqlQuery($sqlUpdateRessurrection, "UpdateRessurrection", $mysqli);
}
// 사용자 데이터를 요청
$sqlFindUserData = "SELECT * FROM `usercore` WHERE `no` = " . $userKeyNo;
$resultFindUserData = SendSqlQuery($sqlFindUserData, "FindUserData", $mysqli);
$dataUserCore = mysqli_fetch_array($resultFindUserData);
// 하트 보유 체크.
if ($dataUserCore["hearts"] < 1) {
    echo "none0";
    $mysqli->close();
    exit;
}
$returnTime = $dataUserCore["loginTime"];
$resultValue = $dataUserCore["hearts"] - 1;
// 하트 1개 차감.
$sqlUpdateHeart = "UPDATE `usercore` SET `hearts` = " . $resultValue;
if ($resultValue == 4) {
    $nowTime = time();
    $returnTime = $nowTime;
    $sqlUpdateHeart = $sqlUpdateHeart . ", `loginTime` = " . $nowTime;
}
$sqlUpdateHeart = $sqlUpdateHeart . " WHERE `no` = " . $userKeyNo;
$resultUpdateHeart = SendSqlQuery($sqlUpdateHeart, "UpdateHeart", $mysqli);
$returnTime = str_pad($resultValue, 10, "0", STR_PAD_LEFT);
$resultHeart = str_pad($resultValue, 3, "0", STR_PAD_LEFT);
echo "done0" . $resultHeart . $returnTime . $resultResurrectionUse . $resultResurrectionCount;
$mysqli->close();
exit;
Example #5
0
        break;
    case 3:
        $sqlUpdate = "UPDATE `usercore` SET `hearts` = `hearts` + " . $datarow["amount"] . " WHERE `no` = " . $userKeyNo;
        break;
    case 10:
        $sqlUpdate = "UPDATE  `friendlist` SET  `state` =2\n        WHERE (`user` =" . $userKeyNo . " AND `friend` =" . $datarow["senderNo"] . ")\n        OR (`user` =" . $datarow["senderNo"] . " AND  `friend` =" . $userKeyNo . ")";
        break;
}
$resultUpdate = SendSqlQuery($sqlUpdate, "Update", $mysqli);
// 메시지삭제
$sqlDeleteMsg = "DELETE FROM `usermessage` WHERE `no` = " . $msgTableKeyNo;
$resultDeleteMsg = SendSqlQuery($sqlDeleteMsg, "DeleteMsg", $mysqli);
//결과처리
if ($msgTypeNo < 10) {
    $sqlUserData = "SELECT * FROM `usercore` WHERE `no` = " . $userKeyNo;
    $resultUserData = SendSqlQuery($sqlUserData, "UserData", $mysqli);
    $dataUser = mysqli_fetch_array($resultUserData);
    switch ($msgTypeNo) {
        case 1:
            echo "done0" . $dataUser["coins"];
            break;
        case 2:
            echo "done0" . $dataUser["gems"];
            break;
        case 3:
            echo "done0" . $dataUser["hearts"];
            break;
    }
    $mysqli->close();
    exit;
} else {
Example #6
0
//
$mysqli->set_charset("utf8");
$userKeyNo = $_REQUEST["userKeyNo"];
$orderId = $_REQUEST["orderId"];
$packageName = $_REQUEST['packageName'];
$productId = $_REQUEST['productId'];
$purchaseTime = $_REQUEST["purchaseTime"];
$purchaseState = $_REQUEST['purchaseState'];
$developerPayload = $_REQUEST['developerPayload'];
$purchaseToken = $_REQUEST["purchaseToken"];
$sqlFindPayload = "SELECT * FROM `inappgoogle` WHERE `user` = " . $userKeyNo . " AND `state` = 1 AND `sku` = '" . $productId . "' AND `payload` = '" . $developerPayload . "'";
$resultFindPayload = SendSqlQuery($sqlFindPayload, "FindPayload", $mysqli);
if ($resultFindPayload->num_rows < 1) {
    //$data_row = mysqli_fetch_array($resultFindPayload);
    //update receipt
    //$sqlUpdateReceipt = "UPDATE `inappgoogle` SET `state` = 10, `receipt`='".$receipt."' WHERE `no`= ".$data_row["no"];
    //$resultUpdateReceipt = SendSqlQuery($sqlUpdateReceipt, "UpdateReceipt", $mysqli);
    echo "0";
    $mysqli->close();
    exit;
}
$data_row = mysqli_fetch_array($resultFindPayload);
//update receipt
$receipt = "{\"orderId\":\"" . $orderId . "\", \"packageName\":\"" . $packageName . "\", \"productId\":\"" . $productId . "\", \"purchaseTime\":\"" . $purchaseTime . "\", \"purchaseState\":\"" . $purchaseState . "\", \"developerPayload\":\"" . $developerPayload . "\", \"purchaseToken\":\"" . $purchaseToken . "\"}";
$sqlUpdateReceipt = "UPDATE `inappgoogle` SET `state` = 2, `receipt`='" . $receipt . "' WHERE `no`= " . $data_row["no"];
$resultUpdateReceipt = SendSqlQuery($sqlUpdateReceipt, "UpdateReceipt", $mysqli);
echo "1";
$mysqli->close();
exit;
//https://www.googleapis.com/androidpublisher/v2/applications/
//[packageName]/purchases/products/[productId]/tokens/[token]
Example #7
0
<?php

// 기본 데이터를 로딩
include "dbHelper.php";
// usercore 테이블 행번호 저장
$userKeyNo = $_REQUEST["userKeyNo"];
// 데이터베이스에 접속
$mysqli = new mysqli($host, $user, $password, $dbname);
if (mysqli_connect_errno()) {
    echo 'Connect faild : ' . mysqli_connect_error() . '\\n';
    $mysqli->close();
    exit;
}
// utf8로 charset 변경
$mysqli->set_charset("utf8");
//check data
$sqlFind1001 = "SELECT * FROM `farmdefence`.`price` WHERE `codeNo` > 100";
$resultFind1001 = SendSqlQuery($sqlFind1001, "Find1001", $mysqli);
if ($resultFind1001->num_rows > 1) {
    echo "error : exist default price data";
    $mysqli->close();
    exit;
}
$sqlInsert = "INSERT INTO `farmdefence`.`price` (`no`, `codeNo`, `price`, `bonus`, `amount`)\nVALUES (NULL, '101', '1100', '0', '10'), (NULL, '102', '5500', '10', '55'),\n(NULL, '103', '11000', '20', '120'), (NULL, '104', '33000', '30', '390'),\n(NULL, '105', '66000', '50', '900'), (NULL, '201', '10', '0', '6000'),\n(NULL, '202', '50', '10', '33000'), (NULL, '203', '120', '20', '86400'),\n(NULL, '204', '250', '30', '195000'),\n(NULL, '301', '5', '0', '5'), (NULL, '302', '5000', '0', '1'),\n(NULL, '1001', '200', '0', '0'),\n(NULL, '1002', '300', '0', '0'), (NULL, '1003', '400', '0', '0'),\n(NULL, '1004', '500', '0', '0'), (NULL, '1005', '600', '0', '0'),\n(NULL, '1006', '800', '0', '0'), (NULL, '1007', '1000', '0', '0'),\n(NULL, '1008', '1200', '0', '0'), (NULL, '1009', '1400', '0', '0'),\n(NULL, '1010', '1700', '0', '0'), (NULL, '1011', '2000', '0', '0'),\n(NULL, '1012', '2300', '0', '0'), (NULL, '1013', '2600', '0', '0'),\n(NULL, '1014', '2900', '0', '0'), (NULL, '1015', '3200', '0', '0'),\n(NULL, '1016', '3500', '0', '0'), (NULL, '1017', '3800', '0', '0'),\n(NULL, '1018', '4100', '0', '0'), (NULL, '1019', '4400', '0', '0'),\n(NULL, '1020', '4800', '0', '0'), (NULL, '1021', '5200', '0', '0'),\n(NULL, '1022', '5600', '0', '0'), (NULL, '1023', '6000', '0', '0'),\n(NULL, '1024', '6400', '0', '0'), (NULL, '1025', '6800', '0', '0'),\n(NULL, '1026', '7200', '0', '0'), (NULL, '1027', '7600', '0', '0'),\n(NULL, '1028', '8000', '0', '0'), (NULL, '1029', '8400', '0', '0'),\n(NULL, '1030', '8900', '0', '0'), (NULL, '1031', '9400', '0', '0'),\n(NULL, '1032', '9900', '0', '0'), (NULL, '1033', '10400', '0', '0'),\n(NULL, '1034', '10900', '0', '0'), (NULL, '1035', '11400', '0', '0'),\n(NULL, '1036', '11900', '0', '0'), (NULL, '1037', '12400', '0', '0'),\n(NULL, '1038', '12900', '0', '0'), (NULL, '1039', '13400', '0', '0'),\n(NULL, '1040', '13900', '0', '0'), (NULL, '2001', '200', '0', '0'),\n(NULL, '2002', '300', '0', '0'), (NULL, '2003', '400', '0', '0'),\n(NULL, '2004', '500', '0', '0'), (NULL, '2005', '600', '0', '0'),\n(NULL, '2006', '800', '0', '0'), (NULL, '2007', '1000', '0', '0'),\n(NULL, '2008', '1200', '0', '0'), (NULL, '2009', '1400', '0', '0'),\n(NULL, '2010', '1700', '0', '0'), (NULL, '2011', '2000', '0', '0'),\n(NULL, '2012', '2300', '0', '0'), (NULL, '2013', '2600', '0', '0'),\n(NULL, '2014', '2900', '0', '0'), (NULL, '2015', '3200', '0', '0'),\n(NULL, '2016', '3500', '0', '0'), (NULL, '2017', '3800', '0', '0'),\n(NULL, '2018', '4100', '0', '0'), (NULL, '2019', '4400', '0', '0'),\n(NULL, '2020', '4800', '0', '0'), (NULL, '2021', '5200', '0', '0'),\n(NULL, '2022', '5600', '0', '0'), (NULL, '2023', '6000', '0', '0'),\n(NULL, '2024', '6400', '0', '0'), (NULL, '2025', '6800', '0', '0'),\n(NULL, '2026', '7200', '0', '0'), (NULL, '2027', '7600', '0', '0'),\n(NULL, '2028', '8000', '0', '0'), (NULL, '2029', '8400', '0', '0'),\n(NULL, '2030', '8900', '0', '0'), (NULL, '2031', '9400', '0', '0'),\n(NULL, '2032', '9900', '0', '0'), (NULL, '2033', '10400', '0', '0'),\n(NULL, '2034', '10900', '0', '0'), (NULL, '2035', '11400', '0', '0'),\n(NULL, '2036', '11900', '0', '0'), (NULL, '2037', '12400', '0', '0'),\n(NULL, '2038', '12900', '0', '0'), (NULL, '2039', '13400', '0', '0'),\n(NULL, '2040', '13900', '0', '0'), (NULL, '3001', '200', '0', '0'),\n(NULL, '3002', '300', '0', '0'), (NULL, '3003', '400', '0', '0'),\n(NULL, '3004', '500', '0', '0'), (NULL, '3005', '600', '0', '0'),\n(NULL, '3006', '800', '0', '0'), (NULL, '3007', '1000', '0', '0'),\n(NULL, '3008', '1200', '0', '0'), (NULL, '3009', '1400', '0', '0'),\n(NULL, '3010', '1700', '0', '0'), (NULL, '3011', '2000', '0', '0'),\n(NULL, '3012', '2300', '0', '0'), (NULL, '3013', '2600', '0', '0'),\n(NULL, '3014', '2900', '0', '0'), (NULL, '3015', '3200', '0', '0'),\n(NULL, '3016', '3500', '0', '0'), (NULL, '3017', '3800', '0', '0'),\n(NULL, '3018', '4100', '0', '0'), (NULL, '3019', '4400', '0', '0'),\n(NULL, '3020', '4800', '0', '0'), (NULL, '3021', '5200', '0', '0'),\n(NULL, '3022', '5600', '0', '0'), (NULL, '3023', '6000', '0', '0'),\n(NULL, '3024', '6400', '0', '0'), (NULL, '3025', '6800', '0', '0'),\n(NULL, '3026', '7200', '0', '0'), (NULL, '3027', '7600', '0', '0'),\n(NULL, '3028', '8000', '0', '0'), (NULL, '3029', '8400', '0', '0'),\n(NULL, '3030', '8900', '0', '0'), (NULL, '3031', '9400', '0', '0'),\n(NULL, '3032', '9900', '0', '0'), (NULL, '3033', '10400', '0', '0'),\n(NULL, '3034', '10900', '0', '0'), (NULL, '3035', '11400', '0', '0'),\n(NULL, '3036', '11900', '0', '0'), (NULL, '3037', '12400', '0', '0'),\n(NULL, '3038', '12900', '0', '0'), (NULL, '3039', '13400', '0', '0'),\n(NULL, '3040', '13900', '0', '0')";
$resultInsert = SendSqlQuery($sqlInsert, "Insert", $mysqli);
echo "complete";
$mysqli->close();
exit;
Example #8
0
// 기본 데이터를 로딩
include "dbHelper.php";
// usercore 테이블 행번호 저장
$userKeyNo = $_REQUEST["userKeyNo"];
// 데이터베이스에 접속
$mysqli = new mysqli($host, $user, $password, $dbname);
if (mysqli_connect_errno()) {
    echo 'Connect faild : ' . mysqli_connect_error() . '\\n';
    $mysqli->close();
    exit;
}
// utf8로 charset 변경
$mysqli->set_charset("utf8");
//
$sqlAllPrice = "SELECT * FROM `price` ORDER BY `no`";
$resultAllPrice = SendSqlQuery($sqlAllPrice, "AllPrice", $mysqli);
//
$dom = new DOMDocument('1.0', 'UTF-8');
//root element
$rootNode = $dom->createElement('farmdefence');
$dom->appendChild($rootNode);
$response = $dom->createElement("price");
$rootNode->appendChild($response);
//db php
while ($datarow = mysqli_fetch_array($resultAllPrice)) {
    $dataNode = $dom->createElement('PriceData');
    $codeNo = nodeMaker($dom, "codeNo", $datarow["codeNo"]);
    $price = nodeMaker($dom, "price", $datarow["price"]);
    $bonus = nodeMaker($dom, "bonus", $datarow["bonus"]);
    $amount = nodeMaker($dom, "amount", $datarow["amount"]);
    $dataNode->appendChild($codeNo);
Example #9
0
<?php

// 기본 데이터를 로딩
include "dbHelper.php";
// usercore 테이블 행번호 저장
$userKeyNo = $_REQUEST["userKeyNo"];
// 데이터베이스에 접속
$mysqli = new mysqli($host, $user, $password, $dbname);
if (mysqli_connect_errno()) {
    echo 'Connect faild : ' . mysqli_connect_error() . '\\n';
    $mysqli->close();
    exit;
}
// utf8로 charset 변경
$mysqli->set_charset("utf8");
// 데이터 생성여부검증
$sqlFind = "SHOW TABLES LIKE 'inappitem'";
$resultFind = SendSqlQuery($sqlFind, "Find", $mysqli);
if ($resultFind->num_rows > 0) {
    echo "error : exist default inapp data";
    $mysqli->close();
    exit;
}
$sqlCreateTable = "CREATE TABLE  `inappitem`\n(`no` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT ,\n `codeNo` INT( 10 ) UNSIGNED NOT NULL DEFAULT  '0',\n  `sku` VARCHAR( 30 ) NOT NULL ,\n   PRIMARY KEY (  `no` ))\n   ENGINE = INNODB DEFAULT CHARSET = utf8";
$resultCreateTable = SendSqlQuery($sqlCreateTable, "CreateTable", $mysqli);
$sqlAddRow = "INSERT INTO `farmdefence`.`inappitem` (`no`, `codeNo`, `sku`) VALUE\n(null, 101, 'add_gem01'), (null, 102, 'add_gem02'), (null, 103, 'add_gem03'),\n(null, 104, 'add_gem04'), (null, 105, 'add_gem05')";
$reslutAddRow = SendSqlQuery($sqlAddRow, "AddRow", $mysqli);
echo "complete";
$mysqli->close();
exit;
Example #10
0
include "dbHelper.php";
//
$userKeyNo = $_REQUEST["userKeyNo"];
//
$mysqli = new mysqli($host, $user, $password, $dbname);
if (mysqli_connect_errno()) {
    echo 'Connect faild : ' . mysqli_connect_error() . '\\n';
    $mysqli->close();
    exit;
}
//
$mysqli->set_charset("utf8");
//
$sqlFindFriend = "SELECT `friendlist`.*, `usercore`.`id` AS `name`, `usercore`.`highScore` AS `score`\n    FROM `friendlist`, `usercore`\n    WHERE `friendlist`.`user` = " . $userKeyNo . " AND `usercore`.`no` = `friendlist`.`friend`";
//
$resultFindFriend = SendSqlQuery($sqlFindFriend, "FindFriend", $mysqli);
//
$dom = new DOMDocument('1.0', 'UTF-8');
//root element
$rootNode = $dom->createElement('farmdefence');
$dom->appendChild($rootNode);
$response = $dom->createElement("friendlist");
$rootNode->appendChild($response);
//db php
while ($datarow = mysqli_fetch_array($resultFindFriend)) {
    $dataNode = $dom->createElement('FriendData');
    $no = nodeMaker($dom, "no", $datarow["no"]);
    $friend = nodeMaker($dom, "friend", $datarow["friend"]);
    $name = nodeMaker($dom, "name", $datarow["name"]);
    $score = nodeMaker($dom, "score", $datarow["score"]);
    $state = nodeMaker($dom, "state", $datarow["state"]);
Example #11
0
}
//결과반영
$sqlUpdateUserCore = "UPDATE `usercore` SET `coins` = `coins` - " . $spendCoins . " WHERE `no` = " . $userKeyNo;
$resultUpdateUserCore = SendSqlQuery($sqlUpdateUserCore, "UpdateUserCore", $mysqli);
$returnAmount = 1;
$sqlFindItem = "SELECT * FROM `useritem` WHERE `user` = " . $userKeyNo . " AND `itemNo` = " . $pID;
$resultFindItem = SendSqlQuery($sqlFindItem, "FindItem", $mysqli);
if ($resultFindItem->num_rows > 0) {
    $dataFindItem = mysqli_fetch_array($resultFindItem);
    $returnAmount = $dataFindItem["amount"] + 1;
    //item을 이미 구매한경우
    $sqlItemUpdate = "UPDATE `useritem` SET `amount` = `amount` + 1 WHERE `user` = " . $userKeyNo . " AND `itemNo` = " . $pID;
    $resultItemUpdate = SendSqlQuery($sqlItemUpdate, "ItemUpdate", $mysqli);
} else {
    $sqlInsertItem = "INSERT INTO `useritem` (`no`, `user`, `itemNo`, `amount`, `use`) VALUES (NULL, " . $userKeyNo . ", " . $pID . ", 1, 0)";
    $resultInsertItem = SendSqlQuery($sqlInsertItem, "InsertItem", $mysqli);
}
$returnCoins = $nowCoins - $spendCoins;
//반환 데이터생성
// 사용자 데이터가 존재하므로 리턴할 XML 데이터 구조 생성
$dom = new DOMDocument('1.0', 'UTF-8');
//root 노드 생성
$rootNode = $dom->createElement('farmdefence');
$dom->appendChild($rootNode);
$coins = nodeMaker($dom, "coins", $returnCoins);
$rAmount = nodeMaker($dom, "amount", $returnAmount);
$rootNode->appendChild($coins);
$rootNode->appendChild($rAmount);
// 반환되는 데이터의 헤더에결과값이 XML 형태라는 것을 명시
header("Content-type: text/xml; charset=UTF-8");
header("Cache-Control: no-cache");
Example #12
0
<?php

// 기본 데이터를 로딩
include "dbHelper.php";
// 값을 전달받아 저장한다.
$userKeyNo = $_REQUEST["userKeyNo"];
$userID = $_REQUEST["userID"];
$friendUserKeyNo = $_REQUEST["friendUserKeyNo"];
$friendTableNo = $_REQUEST["friendTableNo"];
// 데이터베이스에 접속
$mysqli = new mysqli($host, $user, $password, $dbname);
if (mysqli_connect_errno()) {
    echo 'Connect faild : ' . mysqli_connect_error() . '\\n';
    $mysqli->close();
    exit;
}
// utf8로 charset 변경
$mysqli->set_charset("utf8");
$sendTime = time();
//send message
$sqlInsertSendHeartMsg = "INSERT INTO `usermessage`(`no`, `user`, `sender`, `senderNo`, `msgType`, `amount`, `time`)\nVALUES (null, '" . $friendUserKeyNo . "', '" . $userID . "', '" . $userKeyNo . "', '3', '1', '" . $sendTime . "')";
$resultInsertSendHeartMsg = SendSqlQuery($sqlInsertSendHeartMsg, "InsertSendHeartMsg", $mysqli);
//보낸 시간업데이트
$sqlUpdateSendTime = "UPDATE `friendlist` SET `sendTime` = '" . $sendTime . "' WHERE `no` = " . $friendTableNo;
$resultUpdateSendTime = SendSqlQuery($sqlUpdateSendTime, "UpdateSendTime", $mysqli);
echo "done0" . $sendTime . time();
$mysqli->close();
exit;
Example #13
0
$sqlFindUser = "******" . $friendID . "'";
$resultFindUser = SendSqlQuery($sqlFindUser, "FindUser", $mysqli);
if ($resultFindUser->num_rows < 1) {
    echo "none0";
    $mysqli->close();
    exit;
}
// 친구가 될 사용자의 정보 변환.
$dataCore = mysqli_fetch_array($resultFindUser);
$friendKeyNo = $dataCore["no"];
//이미 친구이거나 친구요청을 보내거나받았는지 체크.
$sqlFindFriendRequest = "SELECT * FROM `friendlist`\n    WHERE `user` = " . $userKeyNo . "\n    AND `friend` = " . $friendKeyNo;
$resultFindFriendRequest = SendSqlQuery($sqlFindFriendRequest, "FindFriendRequest", $mysqli);
if ($resultFindFriendRequest->num_rows > 0) {
    // 이미 친구 이거나 친구 요청등을 보낸 경우.
    $dataFriend = mysqli_fetch_array($resultFindFriendRequest);
    $state = $dataFriend["state"];
    echo "have" . $state;
    $mysqli->close();
    exit;
} else {
    // 새로운 친구로 등록하기위한 과정 진행.
    $sendTime = time();
    $sqlInsertFriendRequest = "INSERT INTO `friendlist`(`no`, `user`, `friend`, `state`, `sendTime`)\n        VALUES (null, " . $userKeyNo . ", " . $friendKeyNo . ", 0, " . $sendTime . "),\n        (null, " . $friendKeyNo . ", " . $userKeyNo . ", 1, " . $sendTime . ")";
    $resultInsertFriendRequest = SendSqlQuery($sqlInsertFriendRequest, "InsertFriendRequest", $mysqli);
    //친구요청 메시지 등록.
    $sqlInsertMsg = "INSERT INTO `usermessage`(`no`, `user`, `sender`, `senderNo`, `msgType`, `time`)\n        VALUES (null, " . $friendKeyNo . ", '" . $userID . "', '" . $userKeyNo . "', 10, " . $sendTime . ")";
    $resultInsertMsg = SendSqlQuery($sqlInsertMsg, "InsertMsg", $mysqli);
    echo "done0";
    $mysqli->close();
}
Example #14
0
include "dbHelper.php";
// usercore 테이블 행번호 저장
$userKeyNo = $_REQUEST["userKeyNo"];
$getCoins = $_REQUEST["getCoins"];
$nowScore = $_REQUEST["score"];
// 데이터베이스에 접속
$mysqli = new mysqli($host, $user, $password, $dbname);
if (mysqli_connect_errno()) {
    echo 'Connect faild : ' . mysqli_connect_error() . '\\n';
    $mysqli->close();
    exit;
}
// utf8로 charset 변경
$mysqli->set_charset("utf8");
// 사용자 데이터를 요청
$sqlFindUserData = "SELECT * FROM `usercore` WHERE `no` = " . $userKeyNo;
$resultFindUserData = SendSqlQuery($sqlFindUserData, "FindUserData", $mysqli);
$dataUserCore = mysqli_fetch_array($resultFindUserData);
$resultScore = $dataUserCore["highScore"];
$sqlUpdate = "UPDATE `usercore` SET `coins` = `coins` + " . $getCoins;
if ($nowScore > $dataUserCore["highScore"]) {
    $sqlUpdate = $sqlUpdate . ", `highScore` = " . $nowScore;
    $resultScore = $nowScore;
}
$sqlUpdate = $sqlUpdate . " WHERE `no` = " . $userKeyNo;
$resultUpdate = SendSqlQuery($sqlUpdate, "Update", $mysqli);
$resultCoinsValue = $dataUserCore["coins"] + $getCoins;
$resultCoins = str_pad($resultCoinsValue, 7, "0", STR_PAD_LEFT);
echo 'done0' . $resultCoins . $resultScore;
$mysqli->close();
exit;
$userKeyNo = $_REQUEST["userKeyNo"];
$msgTableKeyNo = $_REQUEST["msgTableKeyNo"];
$msgTypeNo = $_REQUEST["msgTypeNo"];
// 데이터베이스에 접속
$mysqli = new mysqli($host, $user, $password, $dbname);
if (mysqli_connect_errno()) {
    echo 'Connect faild : ' . mysqli_connect_error() . '\\n';
    $mysqli->close();
    exit;
}
// utf8로 charset 변경
$mysqli->set_charset("utf8");
$sqlFindMsg = "SELECT * FROM `usermessage`\n    WHERE `no` = " . $msgTableKeyNo . " AND `user` = " . $userKeyNo . " AND `msgType` = " . $msgTypeNo;
$resultFindMsg = SendSqlQuery($sqlFindMsg, "FindMsg", $mysqli);
if ($resultFindMsg->num_rows < 1) {
    // error : 메시지가 존재하지않는 경우
    echo "none0";
    $mysqli->close();
    exit;
}
$datarow = mysqli_fetch_array($resultFindMsg);
// 친구 리시트에서 삭제
$sqlDelete = "DELETE FROM `friendlist`\n        WHERE (`user` =" . $userKeyNo . " AND `friend` =" . $datarow["senderNo"] . ")\n        OR (`user` =" . $datarow["senderNo"] . " AND  `friend` =" . $userKeyNo . ")";
$resultDelete = SendSqlQuery($sqlDelete, "Delete", $mysqli);
// 메시지삭제
$sqlDeleteMsg = "DELETE FROM `usermessage` WHERE `no` = " . $msgTableKeyNo;
$resultDeleteMsg = SendSqlQuery($sqlDeleteMsg, "DeleteMsg", $mysqli);
//결과처리
echo "done0";
$mysqli->close();
exit;
Example #16
0
$resultPriceData = SendSqlQuery($sqlPriceData, "PriceData", $mysqli);
$dataPriceData = mysqli_fetch_array($resultPriceData);
$spendCoins = $dataPriceData["price"];
$nowCoins = $dataUserCore["coins"];
$afterLv = $dataUpgradeData["attLv"] + 1;
// 코인이부족한경우.
if ($nowCoins < $spendCoins) {
    echo "none1";
    $mysqli->close();
    exit;
}
//결과반영
$sqlUpdateUserCore = "UPDATE `usercore` SET `coins` = `coins` - " . $spendCoins . " WHERE `no` = " . $userKeyNo;
$resultUpdateUserCore = SendSqlQuery($sqlUpdateUserCore, "UpdateUserCore", $mysqli);
$sqlLvUpgrade = "UPDATE `userupgrade` SET `attLv` = " . $afterLv . " WHERE `no` = " . $dataUpgradeData["no"];
$resultLvUpgrade = SendSqlQuery($sqlLvUpgrade, "LvUpgrade", $mysqli);
$returnCoins = $nowCoins - $spendCoins;
//반환 데이터생성
// 사용자 데이터가 존재하므로 리턴할 XML 데이터 구조 생성
$dom = new DOMDocument('1.0', 'UTF-8');
//root 노드 생성
$rootNode = $dom->createElement('farmdefence');
$dom->appendChild($rootNode);
$coins = nodeMaker($dom, "coins", $returnCoins);
$attLv = nodeMaker($dom, "attLv", $afterLv);
$rootNode->appendChild($coins);
$rootNode->appendChild($attLv);
// 반환되는 데이터의 헤더에결과값이 XML 형태라는 것을 명시
header("Content-type: text/xml; charset=UTF-8");
header("Cache-Control: no-cache");
header("Pragma: no-cache");
Example #17
0
<?php

include "dbHelper.php";
//
$userKeyNo = $_REQUEST["userKeyNo"];
//
$mysqli = new mysqli($host, $user, $password, $dbname);
if (mysqli_connect_errno()) {
    echo 'Connect faild : ' . mysqli_connect_error() . '\\n';
    $mysqli->close();
    exit;
}
//
$mysqli->set_charset("utf8");
$userKeyNo = $_REQUEST["userKeyNo"];
$sku = $_REQUEST["sku"];
// 데이터 생성여부검증
$sqlFind = "SHOW TABLES LIKE 'inappgoogle'";
$resultFind = SendSqlQuery($sqlFind, "Find", $mysqli);
if ($resultFind->num_rows < 1) {
    $sqlCreateTable = "CREATE TABLE  `inappgoogle` (\n    `no` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT ,\n     `user` INT( 10 ) UNSIGNED NOT NULL ,\n     `state` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT  '0',\n     `sku` VARCHAR( 10 ) NOT NULL ,\n     `payload` VARCHAR( 18 ) NOT NULL ,\n     `receipt` TEXT NOT NULL ,\n    PRIMARY KEY (  `no` )\n    ) ENGINE = INNODB DEFAULT CHARSET = utf8";
    $resultCreateTable = SendSqlQuery($sqlCreateTable, "CreateTable", $mysqli);
}
$nowpayload = uniqid("fd");
//payload  기록
$sqlRecordPayload = "INSERT INTO `inappgoogle` (`no`, `user`, `state`, `sku`, `payload`) VALUES\n(null, " . $userKeyNo . ", 1, '" . $sku . "', '" . $nowpayload . "')";
$resultRecordPayload = SendSqlQuery($sqlRecordPayload, "RecordPayload", $mysqli);
echo $nowpayload;
$mysqli->close();
exit;
Example #18
0
// 기본 데이터를 로딩
include "dbHelper.php";
// usercore 테이블 행번호 저장
$userKeyNo = $_REQUEST["userKeyNo"];
// 데이터베이스에 접속
$mysqli = new mysqli($host, $user, $password, $dbname);
if (mysqli_connect_errno()) {
    echo 'Connect faild : ' . mysqli_connect_error() . '\\n';
    $mysqli->close();
    exit;
}
// utf8로 charset 변경
$mysqli->set_charset("utf8");
//
$sqlFindItem = "SELECT * FROM `useritem` WHERE `user` = " . $userKeyNo;
$resultFindItem = SendSqlQuery($sqlFindItem, "FindItem", $mysqli);
//
$dom = new DOMDocument('1.0', 'UTF-8');
//root element
$rootNode = $dom->createElement('farmdefence');
$dom->appendChild($rootNode);
$response = $dom->createElement("useritem");
$rootNode->appendChild($response);
//db php
while ($datarow = mysqli_fetch_array($resultFindItem)) {
    $dataNode = $dom->createElement('ItemData');
    $no = nodeMaker($dom, "no", $datarow["no"]);
    $itemNo = nodeMaker($dom, "itemNo", $datarow["itemNo"]);
    $amount = nodeMaker($dom, "amount", $datarow["amount"]);
    $use = nodeMaker($dom, "use", $datarow["use"]);
    $dataNode->appendChild($no);
Example #19
0
//
include "dbHelper.php";
//
$userKeyNo = $_REQUEST["userKeyNo"];
//
$mysqli = new mysqli($host, $user, $password, $dbname);
if (mysqli_connect_errno()) {
    echo 'Connect faild : ' . mysqli_connect_error() . '\\n';
    $mysqli->close();
    exit;
}
//
$mysqli->set_charset("utf8");
//
$sqlFindMsg = "SELECT * FROM `usermessage` WHERE `user` = " . $userKeyNo;
$resultFindMsg = SendSqlQuery($sqlFindMsg, "FindMsg", $mysqli);
//
$dom = new DOMDocument('1.0', 'UTF-8');
//root element
$rootNode = $dom->createElement('farmdefence');
$dom->appendChild($rootNode);
$response = $dom->createElement("usermessage");
$rootNode->appendChild($response);
//db php
while ($datarow = mysqli_fetch_array($resultFindMsg)) {
    $dataNode = $dom->createElement('MessageData');
    $no = nodeMaker($dom, "no", $datarow["no"]);
    $sender = nodeMaker($dom, "sender", $datarow["sender"]);
    $msgType = nodeMaker($dom, "msgType", $datarow["msgType"]);
    $amount = nodeMaker($dom, "amount", $datarow["amount"]);
    $dataNode->appendChild($no);
if ($resultFindCodeNo->num_rows < 1) {
    //sku가 등록되지 않은경우
    echo "noSkuInfo";
    $mysqli->close();
    exit;
}
$data_row = mysqli_fetch_array($resultFindCodeNo);
//price 정보 로딩
$sqlFindPrice = "SELECT * FROM `price` WHERE `codeNo` = " . $data_row["codeNo"];
$resultFindPrice = SendSqlQuery($sqlFindPrice, "FindPrice", $mysqli);
if ($resultFindPrice->num_rows < 1) {
    //price 정보가 없는경우
    echo "noPriceInfo";
    $mysqli->close();
    exit;
}
$dataPrice = mysqli_fetch_array($resultFindPrice);
// 유저정보 갱신
$sqlUpdateGem = "UPDATE `usercore` SET `gems` = `gems` + " . $dataPrice["amount"] . " WHERE `no` = " . $userKeyNo;
$resultUpdateGem = SendSqlQuery($sqlUpdateGem, "UpdateGem", $mysqli);
$dataPayload = mysqli_fetch_array($resultFindPayload);
// 지급되었다고기록
$sqlUpdatePayload = "UPDATE `inappgoogle` SET `state` = 20 WHERE `no` = " . $dataPayload["no"];
$resultUpdatePayload = SendSqlQuery($sqlUpdatePayload, "UpdatePayload", $mysqli);
//유저 보석 총 량 전달
$sqlFindGems = "SELECT `gems` FROM `usercore` WHERE `no` = " . $userKeyNo;
$resultFindGems = SendSqlQuery($sqlFindGems, "FindGems", $mysqli);
$dataGems = mysqli_fetch_array($resultFindGems);
echo $dataGems["gems"];
$mysqli->close();
exit;
Example #21
0
$dataUserCore = mysqli_fetch_array($resultUserCoreData);
$sqlPriceData = "SELECT * FROM `price` WHERE `codeNo` = " . $pID;
$resultPriceData = SendSqlQuery($sqlPriceData, "PriceData", $mysqli);
$dataPriceData = mysqli_fetch_array($resultPriceData);
$spendGems = $dataPriceData["price"];
$nowGems = $dataUserCore["gems"];
$addHearts = $dataPriceData["amount"];
// 보석이부족한경우.
if ($nowGems < $spendGems) {
    echo "none2";
    $mysqli->close();
    exit;
}
//결과반영
$sqlUpdateUserCore = "UPDATE `usercore` SET `gems` = `gems` - " . $spendGems . ",\n `hearts` = `hearts` + " . $addHearts . " WHERE `no` = " . $userKeyNo;
$resultUpdateUserCore = SendSqlQuery($sqlUpdateUserCore, "UpdateUserCore", $mysqli);
$returnGems = $nowGems - $spendGems;
$returnHearts = $dataUserCore["hearts"] + $addHearts;
//반환 데이터생성
// 사용자 데이터가 존재하므로 리턴할 XML 데이터 구조 생성
$dom = new DOMDocument('1.0', 'UTF-8');
//root 노드 생성
$rootNode = $dom->createElement('farmdefence');
$dom->appendChild($rootNode);
$gems = nodeMaker($dom, "gems", $returnGems);
$hearts = nodeMaker($dom, "hearts", $returnHearts);
$rootNode->appendChild($gems);
$rootNode->appendChild($hearts);
// 반환되는 데이터의 헤더에결과값이 XML 형태라는 것을 명시
header("Content-type: text/xml; charset=UTF-8");
header("Cache-Control: no-cache");
Example #22
0
    $mysqli->close();
    exit;
}
// utf8로 charset 변경
$mysqli->set_charset("utf8");
// 사용자의 전체 친구리스트 로딩하여 제외리스트 생성.
$sqlFindAllFriend = "SELECT * FROM `friendlist` WHERE `user` = " . $userKeyNo;
$resultFindAllFriend = SendSqlQuery($sqlFindAllFriend, "FindAllFriend", $mysqli);
$removeList = "(" . $userKeyNo;
while ($datarow = mysqli_fetch_array($resultFindAllFriend)) {
    $removeList = $removeList . ", " . $datarow["friend"];
}
$removeList = $removeList . ")";
// $removeList에 있는 유저를 제외하고 3개 선택.
$sqlFindRecommendedFriend = "SELECT * FROM `usercore` WHERE `no` NOT IN " . $removeList . "\n    ORDER BY RAND() LIMIT 0, 3";
$resultFindRecommenedFriend = SendSqlQuery($sqlFindRecommendedFriend, "FindRecommendedFriend", $mysqli);
// 결과 생성
$dom = new DOMDocument('1.0', 'UTF-8');
//root 노드 생성
$rootNode = $dom->createElement('farmdefence');
$dom->appendChild($rootNode);
$response = $dom->createElement("recommendFriend");
$rootNode->appendChild($response);
while ($datarow = mysqli_fetch_array($resultFindRecommenedFriend)) {
    $dataNode = $dom->createElement('RecommendedData');
    $name = nodeMaker($dom, "name", $datarow["id"]);
    $dataNode->appendChild($name);
    $response->appendChild($dataNode);
}
header("Content-type: text/xml; charset=UTF-8");
header("Cache-Control: no-cache");