コード例 #1
0
function HandleSmartReply($backend, $protocolversion)
{
    global $zpushdtd;
    global $input, $output;
    // Smart reply should add the original message to the end of the message body
    // In some way there could be a header in XML and not only in _GET...
    $data['task'] = 'reply';
    $data['replacemime'] = false;
    // dw2412 Backend should return proper status.
    // For Protocolversion <AS14 everything that is not true results in 400 Bad Request header
    // For Protocolversion >=AS14
    // 115 = SendQuotaExceeded
    // 116 = MessageRecipientUnresolved
    // 117 = MessageReplyNotAllowed
    // 118 = MessagePreviouslySent
    // 119 = MessageHasNoRecipient
    // 120 = MailSubmissionFailed
    // 121 = MessageReplyFailed
    $result = 1;
    if ($protocolversion >= 14.0) {
        $decoder = new WBXMLDecoder($input, $zpushdtd);
        // Since HTC sends AS14.0 Protocol Version but behaves in sendmail as if it is <AS14.0 Protocol in use I compare WBXML Protocol Version and in case it is higher than 0x03 use the
        // old sendmail protocol algorythm
        if ($decoder->version > 0x3) {
            $rfc822 = $decoder->_inputRaw . readStream($input);
            if (isset($_GET["LongId"])) {
                $data['longid'] = $_GET["LongId"];
            } else {
                $data['longid'] = false;
            }
            if (isset($_GET["ItemId"])) {
                $data['itemid'] = $_GET["ItemId"];
            } else {
                $data['itemid'] = false;
            }
            if (isset($_GET["CollectionId"])) {
                $data['folderid'] = $_GET["CollectionId"];
            } else {
                $data['folderid'] = false;
            }
            $result = $backend->SendMail($rfc822, $data, $protocolversion);
            // dw2412: we return Bad Request in case mail could not be send
            // TODO: Maybe another status will mention that mail could not be send.
            if ($result !== true) {
                header("HTTP/1.1 400 Bad Request");
            }
        } else {
            $encoder = new WBXMLEncoder($output, $zpushdtd);
            $mime = false;
            if (!$decoder->getElementStartTag(SYNC_COMPOSEMAIL_SMARTREPLY)) {
                $result = 102;
            }
            while (($tag = $decoder->getElementStartTag(SYNC_COMPOSEMAIL_SAVEINSENTITEMS) ? SYNC_COMPOSEMAIL_SAVEINSENTITEMS : ($decoder->getElementStartTag(SYNC_COMPOSEMAIL_CLIENTID) ? SYNC_COMPOSEMAIL_CLIENTID : ($decoder->getElementStartTag(SYNC_COMPOSEMAIL_MIME) ? SYNC_COMPOSEMAIL_MIME : ($decoder->getElementStartTag(SYNC_COMPOSEMAIL_REPLACEMIME) ? SYNC_COMPOSEMAIL_REPLACEMIME : ($decoder->getElementStartTag(SYNC_COMPOSEMAIL_SOURCE) ? SYNC_COMPOSEMAIL_SOURCE : -1))))) != -1 && $result == 1) {
                switch ($tag) {
                    case SYNC_COMPOSEMAIL_SAVEINSENTITEMS:
                        if ($data['saveinsentitems'] = $decoder->getElementContent()) {
                            $decoder->getElementEndTag();
                        } else {
                            $e = $decoder->peek();
                            if ($e[EN_TYPE] == EN_TYPE_ENDTAG) {
                                $decoder->getElementEndTag();
                            }
                            $data['saveinsentitems'] = true;
                        }
                        break;
                    case SYNC_COMPOSEMAIL_CLIENTID:
                        $data['clientid'] = $decoder->getElementContent();
                        if (!$decoder->getElementEndTag()) {
                            $result = 102;
                        }
                        break;
                    case SYNC_COMPOSEMAIL_MIME:
                        $mime = $decoder->getElementContent();
                        if (!$decoder->getElementEndTag()) {
                            $result = 102;
                        }
                        break;
                    case SYNC_COMPOSEMAIL_SOURCE:
                        while (($tag = $decoder->getElementStartTag(SYNC_COMPOSEMAIL_FOLDERID) ? SYNC_COMPOSEMAIL_FOLDERID : ($decoder->getElementStartTag(SYNC_COMPOSEMAIL_ITEMID) ? SYNC_COMPOSEMAIL_ITEMID : ($decoder->getElementStartTag(SYNC_COMPOSEMAIL_LONGID) ? SYNC_COMPOSEMAIL_LONGID : ($decoder->getElementStartTag(SYNC_COMPOSEMAIL_INSTANCEID) ? SYNC_COMPASEMAIL_INSTANCEID : -1)))) != -1 && $result == 1) {
                            switch ($tag) {
                                case SYNC_COMPOSEMAIL_FOLDERID:
                                    $data['folderid'] = $decoder->getElementContent();
                                    if (!$decoder->getElementEndTag()) {
                                        $result = 102;
                                    }
                                    break;
                                case SYNC_COMPOSEMAIL_ITEMID:
                                    $data['itemid'] = $decoder->getElementContent();
                                    if (!$decoder->getElementEndTag()) {
                                        $result = 102;
                                    }
                                    break;
                                case SYNC_COMPOSEMAIL_LONGID:
                                    $data['longid'] = $decoder->getElementContent();
                                    if (!$decoder->getElementEndTag()) {
                                        $result = 102;
                                    }
                                    break;
                                case SYNC_COMPOSEMAIL_INSTANCEID:
                                    $data['instanceid'] = $decoder->getElementContent();
                                    if (!$decoder->getElementEndTag()) {
                                        $result = 102;
                                    }
                                    break;
                            }
                        }
                        if (isset($data['folderid']) && !isset($data['itemid']) || !isset($data['folderid']) && isset($data['itemid']) || isset($data['longid']) && (isset($data['folderid']) || isset($data['itemid']) || isset($data['instanceid']))) {
                            $result = 103;
                        }
                        if (!$decoder->getElementEndTag()) {
                            // End Source
                            $result = 102;
                        }
                        break;
                    case SYNC_COMPOSEMAIL_REPLACEMIME:
                        $data['replacemime'] = true;
                        break;
                }
            }
            if (!isset($data['longid']) && isset($_GET['LongId'])) {
                $data['longid'] = $_GET['LongId'];
            }
            if (!isset($data['itemid']) && isset($_GET['ItemId'])) {
                $data['itemid'] = $_GET['ItemId'];
            }
            if (!isset($data['folderid']) && isset($_GET['CollectionId'])) {
                $data['itemid'] = $_GET['CollectionId'];
            }
            if ($mime === false) {
                $result = 102;
            }
            if (!isset($data['clientid'])) {
                $result = 103;
            }
            if (!$decoder->getElementEndTag()) {
                // End SmartReply
                $result = 102;
            }
            $rfc822 = $mime;
            if ($result == 1) {
                $result = $backend->SendMail($rfc822, $data, $protocolversion);
            }
            if ($result !== true) {
                $encoder->startWBXML();
                $encoder->startTag(SYNC_COMPOSEMAIL_SMARTREPLY);
                $encoder->startTag(SYNC_COMPOSEMAIL_STATUS);
                $encoder->content($result === true ? "1" : $result);
                $encoder->endTag();
                $encoder->endTag();
            }
        }
    } else {
        if (isset($_GET['LongId'])) {
            $data['longid'] = $_GET['LongId'];
        } else {
            $data['longid'] = false;
        }
        if (isset($_GET["ItemId"])) {
            $data['itemid'] = $_GET["ItemId"];
        } else {
            $data['itemid'] = false;
        }
        if (isset($_GET["CollectionId"])) {
            $data['folderid'] = $_GET["CollectionId"];
        } else {
            $data['folderid'] = false;
        }
        $rfc822 = readStream($input);
        $result = $backend->SendMail($rfc822, $data, $protocolversion);
        // dw2412: we return Bad Request in case mail could not be send
        // TODO: Maybe another status will mention that mail could not be send.
        if ($result !== true) {
            header("HTTP/1.1 400 Bad Request");
        }
    }
    return true;
}
コード例 #2
0
function HandleSmartReply($backend, $protocolversion)
{
    global $input;
    // Smart reply should add the original message to the end of the message body
    $rfc822 = readStream($input);
    if (isset($_GET["ItemId"])) {
        $orig = $_GET["ItemId"];
    } else {
        $orig = false;
    }
    if (isset($_GET["CollectionId"])) {
        $parent = $_GET["CollectionId"];
    } else {
        $parent = false;
    }
    return $backend->SendMail($rfc822, false, $orig, $parent);
}
コード例 #3
0
ファイル: lib.inc.php プロジェクト: v31project/GISTaxi
function setWorkingStatus($mysqli)
{
    $_PUT = readStream();
    $phone = clearData($_PUT['phone'], $mysqli);
    $workingStatus = clearData($_PUT['workingStatus'], $mysqli);
    if ($phone == "" or $workingStatus == "") {
        $output_arr["id"] = 601;
        $output_arr["name"] = "Not all parameters set";
        $data['code'] = 400;
    } else {
        $auth = checkToken($mysqli, $phone);
        if (!empty($auth['id']) or $auth['status'] != "driver") {
            $data['code'] = 400;
            $auth['id'] = 607;
            $auth['name'] = "Invalid TOKEN or PHONE";
            $data['content'] = json_encode($auth);
            return $data;
        }
        $workingStatus = (int) $workingStatus;
        if ($workingStatus == 0 or $workingStatus == 1) {
            $result = $mysqli->query("UPDATE Drivers SET workingStatus={$workingStatus} \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE phone='{$phone}'");
            if (!$result) {
                $output_arr["id"] = 604;
                $output_arr["name"] = "Failed to query: (" . $mysqli->errno . ") " . $mysqli->error;
                $data['code'] = 400;
            } else {
                $output_arr["name"] = "WORKINGSTATUS successfully updated";
                $data['code'] = 200;
            }
        } else {
            $output_arr["id"] = 611;
            $output_arr["name"] = "Invalid parameter WORKINGSTATUS";
            $data['code'] = 400;
        }
    }
    $data['content'] = json_encode($output_arr);
    return $data;
}