Example #1
0
function output($data)
{
    header("Content-Type:text/html; charset=utf-8");
    $r_type = intval($_REQUEST['r_type']);
    //返回数据格式类型; 0:base64;1;json_encode;2:array
    $data['act'] = ACT;
    $data['act_2'] = ACT_2;
    sql_check("wap");
    if ($r_type == 0) {
        require_once APP_ROOT_PATH . 'system/libs/json.php';
        $JSON = new JSON();
        print_r(base64_encode($JSON->encode($data)));
        //	echo base64_encode(json_encode($data));
    } else {
        if ($r_type == 1) {
            //echo APP_ROOT_PATH; exit;
            require_once APP_ROOT_PATH . 'system/libs/json.php';
            //echo 'ss';exit;
            $JSON = new JSON();
            print_r($JSON->encode($data));
            //print_r(json_encode($data));
        } else {
            if ($r_type == 2) {
                print_r($data);
            }
        }
    }
    exit;
}
 /**
  * 新增游戏种类
  * @param unknown_type $gameName
  */
 public function addNewGame($gameName)
 {
     if (empty($gameName)) {
         return new ExcuteResult(ResultStateLevel::ERROR, "游戏名称不能为空!", NULL);
     }
     $sql_check = "SELECT bm_GameID FROM bm_game WHERE bm_GameName = '" . $gameName . "'";
     $r_check = sql_check($sql_check);
     if ($r_check) {
         return new ExcuteResult(ResultStateLevel::ERROR, "游戏名称已存在!", NULL);
     }
     $sql_insert = "INSERT INTO bm_game(bm_GameName) values('" . $gameName . "')";
     $r_insert = sql_insert($sql_insert);
     if ($r_insert != 0) {
         return new ExcuteResult(ResultStateLevel::SUCCESS, "", $r_insert[0]);
     } else {
         return new ExcuteResult(ResultStateLevel::EXCEPTION, "执行出错", NULL);
     }
 }
Example #3
0
 /**
  * 新增游戏道具
  * @param unknown_type $gameID
  * @param unknown_type $itemName
  * @param unknown_type $itemGID
  * @param unknown_type $itemRank
  * @param unknown_type $itemRemark
  */
 public function AddNewGameItem($gameID, $itemName, $itemGID, $itemRank, $itemRemark)
 {
     AddBMAccountEventLog("新增游戏道具物品名称:" . $itemName . ",游戏:" . $gameID . ",游戏GID:" . $itemGID, 2);
     if (!isset($_SESSION['account_ID'])) {
         return new ExcuteResult(ResultStateLevel::ERROR, "账号已登出,请重新登录", "-1");
     }
     $check = "SELECT bm_ItemName FROM bm_item WHERE bm_ItemName = '" . $itemName . "' AND bm_GameID = " . $gameID;
     if (sql_check($check)) {
         return new ExcuteResult(ResultStateLevel::EXCEPTION, "物品名称已存在", $itemName);
     }
     $sql = "insert into bm_item (bm_GameID,bm_ItemName,bm_ItemGID,bm_ItemRank,bm_ItemRemark)";
     $sql .= "values ({$gameID},'{$itemName}','{$itemGID}','{$itemRank}','{$itemRemark}')";
     $r = sql_insert($sql);
     if ($r != 0) {
         return new ExcuteResult(ResultStateLevel::SUCCESS, "", $r[0]);
     } else {
         return new ExcuteResult(ResultStateLevel::EXCEPTION, "执行出错", NULL);
     }
 }
Example #4
0
function update_mail_stats($user_id, $type)
{
    global $dbh;
    if ($type == "suspected_spam") {
        $token = "AND maia_mail_recipients.type IN ('S','P') ";
    } elseif ($type == "suspected_ham") {
        $token = "AND maia_mail_recipients.type = 'H' ";
    } else {
        $token = "AND maia_mail_recipients.type = '' ";
        // shouldn't even be valid
    }
    if (!empty($token)) {
        $sth = $dbh->prepare("SELECT MIN(received_date) AS mindate, " . "MAX(received_date) AS maxdate, " . "MIN(score) AS minscore, " . "MAX(score) AS maxscore, " . "SUM(score) AS totalscore, " . "MIN(size) AS minsize, " . "MAX(size) AS maxsize, " . "SUM(size) AS totalsize, " . "COUNT(id) AS items " . "FROM maia_mail, maia_mail_recipients " . "WHERE maia_mail.id = maia_mail_recipients.mail_id " . $token . "AND maia_mail_recipients.recipient_id = ?");
        $res = $sth->execute(array($user_id));
        sql_check($sth, "update_mail_stats", $res);
        if ($row = $res->fetchrow()) {
            $sth2 = $dbh->prepare("SELECT user_id FROM maia_stats WHERE user_id = ?");
            $res2 = $sth2->execute(array($user_id));
            sql_check($sth2, "update_mail_stats", $sth2);
            // User already has a stats record, update it.
            if ($res2->fetchrow()) {
                $updatesth = $dbh->prepare("UPDATE maia_stats SET oldest_" . $type . "_date = ?, " . "newest_" . $type . "_date = ?, " . "lowest_" . $type . "_score = ?, " . "highest_" . $type . "_score = ?, " . "total_" . $type . "_score = ?, " . "smallest_" . $type . "_size = ?, " . "largest_" . $type . "_size = ?, " . "total_" . $type . "_size = ?, " . "total_" . $type . "_items = ? " . "WHERE user_id = ?");
                $res = $updatesth->execute(array($row["mindate"], $row["maxdate"], isset($row["minscore"]) ? $row["minscore"] : 0, isset($row["maxscore"]) ? $row["maxscore"] : 0, isset($row["totalscore"]) ? $row["totalscore"] : 0, isset($row["minsize"]) ? $row["minsize"] : 0, isset($row["maxsize"]) ? $row["maxsize"] : 0, isset($row["totalsize"]) ? $row["totalsize"] : 0, isset($row["items"]) ? $row["items"] : 0, $user_id));
                sql_check($res, "update_mail_stats", $updatesth);
                // User doesn't have a stats record yet, create a new one for him.
            } else {
                $insertsth = $dbh->prepare("INSERT INTO maia_stats (oldest_" . $type . "_date, " . "newest_" . $type . "_date, " . "lowest_" . $type . "_score, " . "highest_" . $type . "_score, " . "total_" . $type . "_score, " . "smallest_" . $type . "_size, " . "largest_" . $type . "_size, " . "total_" . $type . "_size, " . "total_" . $type . "_items, " . "user_id) " . "VALUES (?,?,?,?,?,?,?,?,?,?)");
                $res = $insertsth->execute(array($row["mindate"], $row["maxdate"], isset($row["minscore"]) ? $row["minscore"] : 0, isset($row["maxscore"]) ? $row["maxscore"] : 0, isset($row["totalscore"]) ? $row["totalscore"] : 0, isset($row["minsize"]) ? $row["minsize"] : 0, isset($row["maxsize"]) ? $row["maxsize"] : 0, isset($row["totalsize"]) ? $row["totalsize"] : 0, isset($row["items"]) ? $row["items"] : 0, $user_id));
                if (PEAR::isError($sth)) {
                    die($sth->getMessage());
                }
            }
            $sth2->free();
        }
        $sth->free();
    }
}
Example #5
0
 /**
  * 新增
  * @param $account
  * @param $name
  * @param $phone
  * @param $mail
  * @param $QQ
  * @param $adress
  * @param $type
  * @param $reamark
  */
 public function AddNew($account, $name, $phone, $mail, $QQ, $adress, $type, $reamark)
 {
     AddBMAccountEventLog("新增账号:" . $account, EventLogTypeEnum::BASEMANGE);
     if (!isset($_SESSION['account_ID'])) {
         return new ExcuteResult(ResultStateLevel::ERROR, "The accounts have been logged out, please re-login account", "-1");
     }
     $check = "SELECT bm_AccountID FROM bm_account WHERE bm_Account = '" . $account . "'";
     if (sql_check($check)) {
         return new ExcuteResult(ResultStateLevel::EXCEPTION, "账号已存在", $account);
     }
     $password = md5("a00000");
     $sql = "insert into bm_account (bm_Account,bm_Password,bm_AccountName,bm_Phone,bm_Email,bm_QQ,bm_Address,bm_AccountType,bm_AccountState,bm_ARemark)";
     $sql .= "values ('{$account}','{$password}','{$name}','{$phone}','{$mail}','{$QQ}','{$adress}','{$type}',0,'{$reamark}')";
     $r = sql_insert($sql);
     if ($r != 0) {
         return new ExcuteResult(ResultStateLevel::SUCCESS, "", $r[0]);
     } else {
         return new ExcuteResult(ResultStateLevel::EXCEPTION, "执行出错", NULL);
     }
 }
Example #6
0
function record_mail_stats($euid, $mail_ids, $type)
{
    global $dbh;
    foreach ((array) $mail_ids as $mail_id) {
        $select = "SELECT received_date, size, score " . "FROM maia_mail WHERE id = ?";
        $sth = $dbh->query($select, array($mail_id));
        sql_check($sth, "record_mail_stats", $select);
        if ($row = $sth->fetchrow()) {
            $mail_received_date = $row["received_date"];
            $mail_size = $row["size"];
            $mail_score = isset($row["score"]) ? $row["score"] : 0;
            $select = "SELECT oldest_" . $type . "_date, " . "newest_" . $type . "_date, " . "lowest_" . $type . "_score, " . "highest_" . $type . "_score, " . "total_" . $type . "_score, " . "smallest_" . $type . "_size, " . "largest_" . $type . "_size, " . "total_" . $type . "_size, " . "total_" . $type . "_items " . "FROM maia_stats WHERE user_id = ?";
            $sth2 = $dbh->query($select, array($euid));
            sql_check($sth2, "record_mail_stats", $select);
            if ($row2 = $sth2->fetchrow()) {
                $oldest_date = $row2["oldest_" . $type . "_date"];
                $newest_date = $row2["newest_" . $type . "_date"];
                $lowest_score = $row2["lowest_" . $type . "_score"];
                $highest_score = $row2["highest_" . $type . "_score"];
                $total_score = $row2["total_" . $type . "_score"];
                $smallest_size = $row2["smallest_" . $type . "_size"];
                $largest_size = $row2["largest_" . $type . "_size"];
                $total_size = $row2["total_" . $type . "_size"];
                $total_items = $row2["total_" . $type . "_items"];
                if ($total_items == 0) {
                    $oldest_date = $mail_received_date;
                    $newest_date = $mail_received_date;
                    $lowest_score = $mail_score;
                    $highest_score = $mail_score;
                    $total_score = $mail_score;
                    $smallest_size = $mail_size;
                    $largest_size = $mail_size;
                    $total_size = $mail_size;
                    $total_items = 1;
                } else {
                    if ($oldest_date == NULL || $mail_received_date < $oldest_date) {
                        $oldest_date = $mail_received_date;
                    }
                    if ($mail_received_date > $newest_date) {
                        $newest_date = $mail_received_date;
                    }
                    if ($mail_score < $lowest_score) {
                        $lowest_score = $mail_score;
                    }
                    if ($mail_score > $highest_score) {
                        $highest_score = $mail_score;
                    }
                    $total_score += $mail_score;
                    if ($mail_size < $smallest_size) {
                        $smallest_size = $mail_size;
                    }
                    if ($mail_size > $largest_size) {
                        $largest_size = $mail_size;
                    }
                    $total_size += $mail_size;
                    $total_items++;
                }
                $update = "UPDATE maia_stats SET oldest_" . $type . "_date = ?, " . "newest_" . $type . "_date = ?, " . "lowest_" . $type . "_score = ?, " . "highest_" . $type . "_score = ?, " . "total_" . $type . "_score = ?, " . "smallest_" . $type . "_size = ?, " . "largest_" . $type . "_size = ?, " . "total_" . $type . "_size = ?, " . "total_" . $type . "_items = ? " . "WHERE user_id = ?";
                $res = $dbh->query($update, array($oldest_date, $newest_date, $lowest_score, $highest_score, $total_score, $smallest_size, $largest_size, $total_size, $total_items, $euid));
                sql_check($res, "maia_record_stats", $update);
            } else {
                $oldest_date = $mail_received_date;
                $newest_date = $mail_received_date;
                $lowest_score = $mail_score;
                $highest_score = $mail_score;
                $total_score = $mail_score;
                $smallest_size = $mail_size;
                $largest_size = $mail_size;
                $total_size = $mail_size;
                $insert = "INSERT INTO maia_stats (oldest_" . $type . "_date, " . "newest_" . $type . "_date, " . "lowest_" . $type . "_score, " . "highest_" . $type . "_score, " . "total_" . $type . "_score, " . "smallest_" . $type . "_size, " . "largest_" . $type . "_size, " . "total_" . $type . "_size, " . "total_" . $type . "_items, " . "user_id) " . "VALUES (?,?,?,?,?,?,?,?,1,?)";
                $res = $dbh->query($insert, array($oldest_date, $newest_date, $lowest_score, $highest_score, $total_score, $smallest_size, $largest_size, $total_size, $euid));
                sql_check($res, "maia_record_stats", $insert);
            }
            $sth2->free();
        }
        $sth->free();
    }
}
Example #7
0
 /**
  * 更新卡的道具绑定信息
  * @param $cardTypeID
  * @param $gameStr
  */
 public function UpdateCardItemInfo($cardTypeID, $gameStr)
 {
     $sqlCheck = "SELECT cd_CardTypeID FROM CD_CardType WHERE cd_CardTypeID = " . $cardTypeID . "AND cardState < 99 ";
     $check = sql_check($sqlCheck);
     if ($check) {
         return new ExcuteResult(ResultStateLevel::EXCEPTION, "卡不存在", $cardTypeID);
     }
     AddBMAccountEventLog("删除卡种类ID:" . $cardTypeID, EventLogTypeEnum::CARDMANAGE);
     if (!isset($_SESSION['account_ID'])) {
         return new ExcuteResult(ResultStateLevel::ERROR, "账号已登出,请重新登录", "-1");
     }
     $sqldel = "delete from cd_cardaffixitem where cd_CardTypeID = " . $cardTypeID;
     $rDell = sql_query($sqldel);
     if ($rDell == 0) {
         return new ExcuteResult(ResultStateLevel::ERROR, "更新卡道具失败");
     }
     if (empty($gameStr)) {
         return new ExcuteResult(ResultStateLevel::SUCCESS, "", NULL);
     }
     $arr = array("NULL" => $cardTypeID);
     $addStr = strtr($gameStr, $arr);
     $sqladd = "insert into cd_cardaffixitem (cd_CardTypeID,bm_ItemID,cd_CardItemNum) values " . $addStr;
     $add = sql_query($sqladd);
     if ($add == 0) {
         return new ExcuteResult(ResultStateLevel::ERROR, "非常抱歉,更新卡道具失败,原先的道具绑定已删除!", $sqladd);
     } else {
         return new ExcuteResult(ResultStateLevel::SUCCESS, "", NULL);
     }
 }
Example #8
0
 /**
  * 修改卡种类游戏限制
  * @param unknown_type $cardID
  * @param unknown_type $limit
  * @param unknown_type $gameStr
  */
 public function UpdateCardLimit($cardID, $limit, $gameStr)
 {
     $sqlCheck = "SELECT cd_CardTypeID FROM CD_CardType WHERE cd_CardTypeID = " . $cardID . "AND cardState < 99 ";
     $check = sql_check($sqlCheck);
     if ($check) {
         return new ExcuteResult(ResultStateLevel::EXCEPTION, "卡不存在", $cardID);
     }
     AddBMAccountEventLog("修改卡种类限制ID:" . $cardID . ",限制:" . $limit, EventLogTypeEnum::CARDMANAGE);
     if (!isset($_SESSION['account_ID'])) {
         return new ExcuteResult(ResultStateLevel::ERROR, "账号已登出,请重新登录", "-1");
     }
     $sqlDel = "delete from CD_CardGameType where cd_CardTypeID = " . $cardID;
     $r = sql_query($sqlDel);
     $msg = "";
     if ($r == 0) {
         $msg .= "卡原先的限制清除失败!";
     }
     if (!empty($gameStr)) {
         $arr = array("NULL" => $cardID);
         $addStr = strtr($gameStr, $arr);
         $sqladd = "insert into CD_CardGameType (cd_CardTypeID,bm_GameID,bm_AreaID,bm_ServerID) values " . $addStr;
         $add = sql_query($sqladd);
         if ($add == 0) {
             $msg .= "卡限制修改失败!";
         }
     }
     if ($limit != "") {
         $sqlUpdate = "UPDATE CD_CardType SET cd_GameRestrict = " . $limit . " WHERE cd_CardTypeID = {$cardID}";
         $r_update = sql_query($sqlUpdate);
         if ($r_update == 0) {
             $msg .= "更改卡状态信息失败!";
         }
     }
     return new ExcuteResult(ResultStateLevel::SUCCESS, $msg, NULL);
 }
Example #9
0
 /**
  * 显示页面函数
  *
  * @access  public
  * @param   string      $filename
  * @param   sting      $cache_id
  *
  * @return  void
  */
 function display($filename, $cache_id = '', $is_return = false)
 {
     $this->_seterror++;
     error_reporting(E_ALL ^ E_NOTICE);
     $this->_checkfile = false;
     $out = $this->fetch($filename, $cache_id);
     if (strpos($out, $this->_hash) !== false) {
         $k = explode($this->_hash, $out);
         foreach ($k as $key => $val) {
             if ($key % 2 == 1) {
                 $k[$key] = $this->insert_mod($val);
             }
         }
         $out = implode('', $k);
     }
     error_reporting($this->_errorlevel);
     $this->_seterror--;
     sql_check();
     if ($is_return) {
         return $out;
     } else {
         gzip_out($out . run_info());
     }
     if ($GLOBALS['distribution_cfg']['OSS_TYPE'] && $GLOBALS['distribution_cfg']['OSS_TYPE'] == "ES_FILE") {
         if (count($GLOBALS['curl_param']['images']) > 0) {
             $GLOBALS['curl_param']['images'] = base64_encode(serialize($GLOBALS['curl_param']['images']));
             curl_setopt($GLOBALS['syn_image_ci'], CURLOPT_POSTFIELDS, $GLOBALS['curl_param']);
             $rss = curl_exec($GLOBALS['syn_image_ci']);
         }
         curl_close($GLOBALS['syn_image_ci']);
         //echo $rss;exit;
     }
 }
Example #10
0
function delete_domain($domain_id)
{
    global $dbh;
    // Delete all admin references to this domain.
    delete_domain_admin_references($domain_id);
    // Delete the domain record itself.
    $delete = "DELETE FROM maia_domains WHERE id = ?";
    $res = $dbh->query($delete, array($domain_id));
    sql_check($res, "delete_domain", $delete);
    // Find and delete the default user records associated with this domain
    $select = "SELECT maia_user_id FROM users WHERE maia_domain_id = ?";
    $sth = $dbh->query($select, array($domain_id));
    sql_check($sth, "delete_domain", $select);
    if ($row = $sth->fetchrow()) {
        $maia_user_id = $row["maia_user_id"];
        delete_user($maia_user_id);
    }
    $sth->free();
}
function rescue_item($user_id, $mail_id, $resend = false)
{
    global $dbh, $logger;
    $select = "SELECT sender_email, contents, " . "envelope_to, maia_mail_recipients.type " . "FROM maia_mail, maia_mail_recipients " . "WHERE maia_mail.id = maia_mail_recipients.mail_id " . "AND maia_mail_recipients.recipient_id = ? " . "AND maia_mail_recipients.mail_id = ?";
    $sth = $dbh->query($select, array($user_id, $mail_id));
    sql_check($sth, "rescue_item", $select);
    if ($row = $sth->fetchrow()) {
        $sender_email = $row["sender_email"];
        $body = $row["contents"];
        $type = $row["type"];
        if (extension_loaded('mcrypt')) {
            if (text_is_encrypted($body)) {
                $key = get_encryption_key();
                $body = decrypt_text($key, $body);
            }
        }
        if (is_a_domain_default_user($user_id)) {
            // System default user (@.) or domain-class user (e.g. @domain)
            $my_email_address = $row["envelope_to"];
        } else {
            // Regular user (e.g. user@domain)
            $rlist = explode(" ", trim($row["envelope_to"]));
            $select = "SELECT email FROM users " . "WHERE maia_user_id = ? " . "AND email = ?";
            $my_email_address = "";
            foreach ($rlist as $rmail) {
                $sth2 = $dbh->query($select, array($user_id, $rmail));
                sql_check($sth2, "rescue_item", $select);
                if ($row2 = $sth2->fetchrow()) {
                    $my_email_address = $row2["email"];
                    $sth2->free();
                    break;
                }
                $sth2->free();
            }
        }
        if (!empty($my_email_address)) {
            if ($resend || $type != 'P') {
                // don't send if it is a labeled fp
                $smtp_result = smtp_send($sender_email, $my_email_address, $body);
            } else {
                $smtp_result = "200 no delivery needed";
            }
            if (($succeeded = strncmp($smtp_result, "2", 1) == 0) || $type == 'P') {
                if (!$resend) {
                    if ($type == 'S' || $type == 'P') {
                        record_mail_stats($user_id, $mail_id, "fp");
                        if (get_user_value($user_id, "auto_whitelist") == "Y") {
                            add_address_to_wb_list($user_id, $sender_email, "W");
                        }
                    }
                    set_item_confirmations('G', $user_id, $mail_id);
                }
            } else {
                $logger->err("rescue attempt failed! " . $smtp_result);
            }
        } else {
            $smtp_result = $lang['text_rescue_error'] . "(EmptyAddress)";
            // code really shouldn't be here.
        }
    } else {
        $smtp_result = $lang['text_rescue_error'] . "(MessageNotFound)";
        // code really shouldn't be here.
    }
    $sth->free();
    $logger->info($smtp_result);
    return $smtp_result;
}