Ver código fonte

Restructured files

Maurits van der Schee 9 anos atrás
pai
commit
7d8c2b5e9a
4 arquivos alterados com 11 adições e 11 exclusões
  1. 5
    5
      .htaccess
  2. 6
    0
      index.php
  3. 0
    3
      list.php
  4. 0
    3
      read.php

+ 5
- 5
.htaccess Ver arquivo

@@ -3,20 +3,20 @@ RewriteBase /api/
3 3
 
4 4
 RewriteCond %{REQUEST_METHOD} GET
5 5
 RewriteCond %{REQUEST_FILENAME} !-f
6
-RewriteRule ^(.*)/(.*)$ read.php?table=$1&key=$2 [L,QSA]
6
+RewriteRule ^(.*)/(.*)$ index.php?action=read&table=$1&key=$2 [L,QSA]
7 7
 
8 8
 RewriteCond %{REQUEST_METHOD} GET
9 9
 RewriteCond %{REQUEST_FILENAME} !-f
10
-RewriteRule ^(.*)$ list.php?table=$1 [L,QSA]
10
+RewriteRule ^(.*)$ index.php?action=list&table=$1 [L,QSA]
11 11
 
12 12
 RewriteCond %{REQUEST_METHOD} POST
13 13
 RewriteCond %{REQUEST_FILENAME} !-f
14
-RewriteRule ^(.*)$ create.php?table=$1 [L,QSA]
14
+RewriteRule ^(.*)$ index.php?action=create&table=$1 [L,QSA]
15 15
 
16 16
 RewriteCond %{REQUEST_METHOD} PUT
17 17
 RewriteCond %{REQUEST_FILENAME} !-f
18
-RewriteRule ^(.*)/(.*)$ update.php?table=$1&key=$2 [L,QSA]
18
+RewriteRule ^(.*)/(.*)$ index.php?action=update&table=$1&key=$2 [L,QSA]
19 19
 
20 20
 RewriteCond %{REQUEST_METHOD} DELETE
21 21
 RewriteCond %{REQUEST_FILENAME} !-f
22
-RewriteRule ^(.*)/(.*)$ delete.php?table=$1&key=$2 [L,QSA]
22
+RewriteRule ^(.*)/(.*)$ index.php?action=delete&table=$1&key=$2 [L,QSA]

+ 6
- 0
index.php Ver arquivo

@@ -0,0 +1,6 @@
1
+<?php
2
+include "config.php";
3
+
4
+$action = preg_replace('/[^a-z]/','',isset($_GET["action"])?$_GET["action"]:'list');
5
+
6
+if (in_array($action,array('list','read','create','update','delete'))) include $action.'.php';

+ 0
- 3
list.php Ver arquivo

@@ -1,6 +1,4 @@
1 1
 <?php
2
-include "config.php";
3
-
4 2
 $table = str_replace('*','%',preg_replace('/[^a-zA-Z0-9\-_*,]/','',isset($_GET["table"])?$_GET["table"]:'*'));
5 3
 $callback = preg_replace('/[^a-zA-Z0-9\-_]/','',isset($_GET["callback"])?$_GET["callback"]:false);
6 4
 $page = preg_replace('/[^0-9:]/','',isset($_GET["page"])?$_GET["page"]:false);
@@ -8,7 +6,6 @@ $filter = isset($_GET["filter"])?$_GET["filter"]:false;
8 6
 $match = isset($_GET["match"])&&in_array($_GET["match"],array('any','start','end','exact','lower','upto','from','higher'))?$_GET["match"]:'start';
9 7
 
10 8
 $mysqli = new mysqli($config["hostname"], $config["username"], $config["password"], $config["database"]);
11
-
12 9
 if ($mysqli->connect_errno) die('Connect failed: '.$mysqli->connect_error);
13 10
 
14 11
 $tablelist = explode(',',$table);

+ 0
- 3
read.php Ver arquivo

@@ -1,12 +1,9 @@
1 1
 <?php
2
-include "config.php";
3
-
4 2
 $key = preg_replace('/[^a-zA-Z0-9\-_]/','',isset($_GET["key"])?$_GET["key"]:false);
5 3
 $table = preg_replace('/[^a-zA-Z0-9\-_]/','',isset($_GET["table"])?$_GET["table"]:false);
6 4
 $callback = preg_replace('/[^a-zA-Z0-9\-_]/','',isset($_GET["callback"])?$_GET["callback"]:false);
7 5
 
8 6
 $mysqli = new mysqli($config["hostname"], $config["username"], $config["password"], $config["database"]);
9
-
10 7
 if ($mysqli->connect_errno) die('Connect failed: '.$mysqli->connect_error);
11 8
 
12 9
 $tables = array();

Carregando…
Cancelar
Salvar