* * 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. * */ // Load Composer's class loader require __DIR__ . "/vendor/autoload.php"; ini_set('display_errors', true); /***************************************************************************/ $config = \Smalldb\Rest\Application::loadConfig(__DIR__); $smalldb = \Smalldb\Rest\Application::createSmalldb($config); $auth = $smalldb->getContext('auth'); $session_machine = $auth->getSessionMachine(); $session_state_diagram_url = './api-v1-diagram.php?machine=session&format=svg'; $user_state_diagram_url = './api-v1-diagram.php?machine=user&format=svg'; $status = []; if (isset($_POST['action'])) { switch ($_POST['action']) { case 'login': list($user, $password) = explode(':', $_POST['credentials']); $status[] = sprintf('Login: user = %s, password = %s', var_export($user, true), var_export($password, true)); if ($session_machine->login($user, $password)) { $status[] = 'Login ok.'; } else { $status[] = 'Login failed.'; }