<?php

/*
 * Copyright 2014 AT&T
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
session_start();
require __DIR__ . '/../config.php';
require_once __DIR__ . '/../lib/Util/Util.php';
use Att\Api\Util\Util;
$arr = array('authenticated' => true, 'server_time' => Util::getServerTime(), 'download' => $linkDownload, 'github' => $linkGithub);
if (isset($_SESSION['savedData'])) {
    $arr['savedData'] = json_decode($_SESSION['savedData'], true);
}
echo json_encode($arr);
<?php

/*
 * Copyright 2015 AT&T
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
session_start();
require_once __DIR__ . '/../config.php';
require_once __DIR__ . '/common.php';
require_once __DIR__ . '/../lib/Util/Util.php';
use Att\Api\Util\Util;
$arr = array('authenticated' => isSessionAuthenticated(), 'redirect_url' => getCodeLocation(), 'server_time' => Util::getServerTime(), 'download' => LINK_DOWNLOAD, 'github' => LINK_GITHUB);
if (isset($_SESSION['savedData'])) {
    $arr['savedData'] = json_decode($_SESSION['savedData'], true);
}
echo json_encode($arr);
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
                        target="_blank">Download<img src="images/download.png" alt="Link"></a>
                    <span class="divider">|&nbsp;</span>
                </li>
                <li><a href="<?php 
echo $linkHelp;
?>
" target="_blank">Help</a></li>
                <li id="back"><a href="#top">Back to top</a></li>
            </ul> <!-- end of links -->
        </div> <!-- end of header -->
        <div class="content">
            <div class="contentHeading">
                <h1>AT&amp;T Sample Application - Text To Speech</h1>
                <div id="introtext">
                    <div><b>Server Time:&nbsp;</b><?php 
echo Util::getServerTime();
?>
</div>
                    <div>
                        <b>Client Time:&nbsp;</b>
                        <script>
                            document.write("" + new Date());
                        </script>
                    </div>
                    <div>
                        <b>User Agent:&nbsp;</b>
                        <script>
                        document.write("" + navigator.userAgent);
                        </script>
                    </div>
                </div> <!-- end of introtext -->
<?php

/*
 * Copyright 2014 AT&T
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
session_start();
require __DIR__ . '/../config.php';
require_once __DIR__ . '/../lib/Util/Util.php';
use Att\Api\Util\Util;
$path = __DIR__ . '/../template/';
$xGrammar = $path . 'x-grammar.txt';
$xDictionary = $path . 'x-dictionary.txt';
$arr = array('authenticated' => true, 'server_time' => Util::getServerTime(), 'download' => $linkDownload, 'github' => $linkSource, 'x_grammar' => file_get_contents($xGrammar), 'x_dictionary' => file_get_contents($xDictionary));
if (isset($_SESSION['savedData'])) {
    $arr['savedData'] = json_decode($_SESSION['savedData'], true);
}
echo json_encode($arr);
<?php

/*
 * Copyright 2015 AT&T
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
session_start();
require_once __DIR__ . '/../config.php';
require_once __DIR__ . '/common.php';
require_once __DIR__ . '/../lib/Util/Util.php';
use Att\Api\Util\Util;
$subscriptionActive = isset($_SESSION['subscriptionId']) ? true : false;
$arr = array('authenticated' => isSessionAuthenticated(), 'redirect_url' => getCodeLocation(), 'server_time' => Util::getServerTime(), 'download' => LINK_DOWNLOAD, 'github' => LINK_GITHUB, 'notificationChannel' => array('channelId' => CHANNEL_ID, 'channelType' => CHANNEL_TYPE, 'maxEvents' => MAX_EVENTS, 'contentType' => CONTENT_TYPE), 'subscriptionActive' => $subscriptionActive);
if (isset($_SESSION['savedData'])) {
    $arr['savedData'] = json_decode($_SESSION['savedData'], true);
}
echo json_encode($arr);
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
<?php

/*
 * Copyright 2015 AT&T
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
session_start();
require_once __DIR__ . '/../config.php';
require_once __DIR__ . '/common.php';
require_once __DIR__ . '/../lib/Util/Util.php';
use Att\Api\Util\Util;
$arr = array('authenticated' => true, 'server_time' => Util::getServerTime(), 'download' => LINK_DOWNLOAD, 'github' => LINK_GITHUB, 'short_code_check' => GET_MSGS_SHORT_CODE, 'short_code_received' => RECEIVE_MSGS_SHORT_CODE);
if (isset($_SESSION['savedData'])) {
    $arr['savedData'] = json_decode($_SESSION['savedData'], true);
}
echo json_encode($arr);
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
use Att\Api\Util\Util;
$postBody = file_get_contents('php://input');
if (strpos($postBody, "<SenderAddress>tel:+") == 0) {
    exit;
}
if (!is_dir($imagesPath)) {
    mkdir($imagesPath);
}
$messages = FileUtil::loadArray($imagesDbPath);
$message = array();
preg_match("@<SenderAddress>tel:(.*)</SenderAddress>@i", $postBody, $matches);
$addr = $matches[1];
$message["address"] = preg_replace('/\\d\\d\\d($)/', '***${1}', $addr);
preg_match("@<subject>(.*)</subject>@i", $postBody, $matches);
$message["subject"] = $matches[1];
$message["date"] = Util::getServerTime();
$message["id"] = count($messages);
mkdir($imagesPath . '/' . $message["id"]);
$boundaryParts = explode("--Nokia-mm-messageHandler-BoUnDaRy", $postBody);
foreach ($boundaryParts as $mimePart) {
    if (!preg_match("@BASE64@", $mimePart)) {
        continue;
    }
    $mmPart = explode("BASE64", $mimePart);
    $filename = null;
    $contentType = null;
    if (preg_match("@Name=([^;^\n]+)@i", $mmPart[0], $matches)) {
        $filename = trim($matches[1]);
    }
    if (preg_match("@Content-Type:([^;^\n]+)@i", $mmPart[0], $matches)) {
        $contentType = trim($matches[1]);
<?php

/*
 * Copyright 2014 AT&T
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
session_start();
require __DIR__ . '/../config.php';
require_once __DIR__ . '/../lib/Util/Util.php';
use Att\Api\Util\Util;
$arr = array('authenticated' => true, 'server_time' => Util::getServerTime(), 'download' => $linkDownload, 'github' => $linkGithub, 'notificationShortcode' => $notificationShortcode);
if (isset($_SESSION['savedData'])) {
    $arr['savedData'] = json_decode($_SESSION['savedData'], true);
}
echo json_encode($arr);
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */