private function saveFile($fileArr) { FileUtil::saveArray($fileArr, $this->_fpath); }
<?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ require_once __DIR__ . '/../lib/Util/FileUtil.php'; use Att\Api\Util\FileUtil; $path = __DIR__; $fname = $path . '/status.db'; $postBody = file_get_contents('php://input'); $asArray = true; $messageInfo = json_decode($postBody, $asArray); $statusarr = FileUtil::loadArray($fname); $statusarr[] = $messageInfo; // TODO: Put value into config while (count($statusarr) > 5) { array_shift($statusarr); } FileUtil::saveArray($statusarr, $fname);
<?php require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../lib/Util/FileUtil.php'; use Att\Api\Util\FileUtil; $postBody = file_get_contents('php://input'); $asArray = true; $messageInfo = json_decode($postBody, $asArray); $statusarr = FileUtil::loadArray(STATUS_FILE); $statusarr[] = $messageInfo; // TODO: Put value into config while (count($statusarr) > 5) { array_shift($statusarr); } FileUtil::saveArray($statusarr, STATUS_FILE); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
<?php require_once __DIR__ . '/lib/Payment/NotificationDetails.php'; require_once __DIR__ . '/lib/Util/FileUtil.php'; use Att\Api\Payment\NotificationDetails; use Att\Api\Util\FileUtil; $rawXml = file_get_contents('php://input'); $details = NotificationDetails::fromXml($rawXml); $arr = array('type' => $details->getNotificationType(), 'timestamp' => $details->getTimestamp(), 'effective' => $details->getEffective(), 'networkOperatorId' => $details->getNetworkOperatorId(), 'ownerIdentifier' => $details->getOwnerIdentifier(), 'purchaseDate' => $details->getPurchaseDate(), 'productIdentifier' => $details->getProductIdentifier(), 'purchaseActivityIdentifier' => $details->getPurchaseActivityIdentifier(), 'instanceIdentifier' => $details->getInstanceIdentifier(), 'minIdentifier' => $details->getMinIdentifier(), 'oldMinIdentifier' => $details->getOldMinIdentifier(), 'sequenceNumber' => $details->getSequenceNumber(), 'reasonCode' => $details->getReasonCode(), 'reasonMessage' => $details->getReasonMessage(), 'vendorPurchaseIdentifier' => $details->getVendorPurchaseIdentifier()); $notifications = FileUtil::loadArray('notifications.db'); $notifications[] = $arr; // limit on the number of entires // TODO: Get limit from config while (count($notifications) > 5) { array_shift($notifications); } FileUtil::saveArray($notifications, 'notifications.db');
<?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../lib/Util/FileUtil.php'; use Att\Api\Util\FileUtil; $postBody = file_get_contents('php://input'); $messageInfo = json_decode($postBody, true); $msgsarr = FileUtil::loadArray(MSGS_FILE); // TODO: Put value into config while (count($msgsarr) > 5) { array_shift($msgsarr); } $msgsarr[] = $messageInfo; FileUtil::saveArray($msgsarr, MSGS_FILE);
$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]); } if ($contentType == null || $filename == null) { continue; } $base64Data = base64_decode($mmPart[1]); $filePath = $imagesPath . '/' . $message['id'] . '/' . $filename; $relativePath = $imagesPathName . '/' . $message['id'] . '/' . $filename; if (preg_match("@image@", $contentType)) { $message["image"] = $relativePath; } if (preg_match("@text@", $contentType)) { $message["text"] = $relativePath; } if (!($fileHandle = fopen($filePath, 'w'))) { die("Unable to open {$filePath}"); } fwrite($fileHandle, $base64Data); fclose($fileHandle); } // TODO: set a limit on the number of messages saved $messages[] = $message; FileUtil::saveArray($messages, $imagesDbPath); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
<?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ require_once __DIR__ . '/../lib/Util/FileUtil.php'; use Att\Api\Util\FileUtil; $path = __DIR__; $fname = $path . '/msgs.db'; $postBody = file_get_contents('php://input'); $asArray = true; $messageInfo = json_decode($postBody, $asArray); $msgsarr = FileUtil::loadArray($fname); // TODO: Put value into config while (count($msgsarr) > 5) { array_shift($msgsarr); } $msgsarr[] = $messageInfo; FileUtil::saveArray($msgsarr, $fname);
* * 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. */ require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../lib/Util/FileUtil.php'; use Att\Api\Util\FileUtil; // TODO: set a limit on the number of notifications saved // currently the number will keep growing without bound $rawNotification = file_get_contents('php://input'); $notifications = json_decode($rawNotification, true); if ($notifications == null) { return; } $arr = FileUtil::loadArray(NOTIFICATION_FILE); $msgNotifications = null; if (isset($notifications['notifications'])) { $msgNotifications = $notifications['notification']; } else { $msgNotifications = $notifications['messageNotifications']; } if (isset($msgNotifications['subscriptions'])) { $arr[] = $msgNotifications['subscriptions']; } else { $arr[] = $msgNotifications['subscriptionNotifications']; } FileUtil::saveArray($arr, NOTIFICATION_FILE); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */