"; echo ''; echo ''; $files = glob(QUEUE_PATH . DIRECTORY_SEPARATOR . '*'); foreach ($files as $file) { $id = pathinfo($file, PATHINFO_FILENAME); if ($data = parseFileData($file)) { echo "{$data['phone']}{$data['message']}"; rename($file, SUCCESS_PATH . DIRECTORY_SEPARATOR . $id); } else { rename($file, BAD_PATH . DIRECTORY_SEPARATOR . $id); } } echo ''; echo ''; } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['from'], $_POST['text'])) { $from = $_POST['from']; $message = $_POST['text']; $filename = prepareFilename(SMS_PATH, ID_LENGHT); $result = createQueueItem($filename, array('phone' => $from, 'message' => $message ), SMS_PATH); if ($result) { echo 'OK'; } else { echo 'ERROR'; } } } ?>