예제 #1
0
 /**
  * REST actions
  *
  * This function contains the REST actions with the assignments to
  * the functions.
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(DBSetting::getPrefix() . ',course,link', dirname(__FILE__));
     // runs the DBSetting
     if ($com->used()) {
         return;
     }
     $this->_conf = $com;
     // initialize slim
     $this->_app = new \Slim\Slim(array('debug' => true));
     $this->_app->response->headers->set('Content-Type', 'application/json');
     // POST AddCourse
     $this->_app->post('(/:pre)/course', array($this, 'addCourse'));
     // POST DeleteCourse
     $this->_app->delete('(/:pre)/course/:courseid', array($this, 'deleteCourse'));
     // PUT EditSetting
     $this->_app->put('(/:pre)/' . $this->getPrefix() . '/setting/:setid', array($this, 'editSetting'));
     // DELETE DeleteSetting
     $this->_app->delete('(/:pre)/' . $this->getPrefix() . '/setting/:setid', array($this, 'deleteSetting'));
     // POST AddSetting
     $this->_app->post('(/:pre)/' . $this->getPrefix() . '/course/:courseid', array($this, 'addSetting'));
     // GET GetExistsCourseSettings
     $this->_app->get('(/:pre)/link/exists/course/:courseid', array($this, 'getExistsCourseSettings'));
     // GET GetCourseSettings
     $this->_app->get('(/:pre)/' . $this->getPrefix() . '/course/:courseid', array($this, 'getCourseSettings'));
     // GET GetSetting
     $this->_app->get('(/:pre)/' . $this->getPrefix() . '/setting/:setid', array($this, 'getSetting'));
     // GET GetSettingByName
     $this->_app->get('(/:pre)/' . $this->getPrefix() . '/course/:courseid/name/:setname', array($this, 'getSettingByName'));
     // run Slim
     $this->_app->run();
 }
예제 #2
0
 /**
  * REST actions
  *
  * This function contains the REST actions with the assignments to
  * the functions.
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(DBAttachment2::getPrefix() . ',course,link', dirname(__FILE__));
     // runs the DBAttachment2
     if ($com->used()) {
         return;
     }
     $this->_conf = $com;
     // initialize slim
     $this->_app = new \Slim\Slim(array('debug' => true));
     $this->_app->response->headers->set('Content-Type', 'application/json');
     // POST AddCourse
     $this->_app->post('(/:pre)/course(/)', array($this, 'addCourse'));
     // POST DeleteCourse
     $this->_app->delete('(/:pre)/course/:courseid(/)', array($this, 'deleteCourse'));
     // PUT EditAttachment
     $this->_app->put('(/:pre)/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'editAttachment'));
     // DELETE DeleteAttachment
     $this->_app->delete('(/:pre)/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'deleteAttachment'));
     // POST AddAttachment
     $this->_app->post('(/:pre)/' . $this->getPrefix(), array($this, 'addAttachment'));
     // GET GetExistsCourseAttachments
     $this->_app->get('(/:pre)/link/exists/course/:courseid(/)', array($this, 'getExistsCourseAttachments'));
     // GET GetAttachment
     $this->_app->get('(/:pre)/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'getAttachment'));
     // GET GetExerciseAttachments
     $this->_app->get('(/:pre)/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'getExerciseAttachments'));
     // GET GetSheetAttachments
     $this->_app->get('(/:pre)/' . $this->getPrefix() . '/exercisesheet/:esid(/)', array($this, 'getSheetAttachments'));
     // GET GetCourseAttachments
     $this->_app->get('(/:pre)/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'getCourseAttachments'));
     // run Slim
     $this->_app->run();
 }
예제 #3
0
 /**
  * REST actions
  *
  * This function contains the REST actions with the assignments to
  * the functions.
  *
  * @param Component $conf component data
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(LCourse::getPrefix(), dirname(__FILE__));
     // runs the LCourse
     if ($com->used()) {
         return;
     }
     $conf = $com->loadConfig();
     // initialize slim
     $this->app = new \Slim\Slim(array('debug' => true));
     $this->app->response->headers->set('Content-Type', 'application/json');
     // initialize component
     $this->_conf = $conf;
     $this->query = CConfig::getLink($conf->getLinks(), "controller");
     $this->_deleteCourse = CConfig::getLinks($conf->getLinks(), "deleteCourse");
     $this->_postCourse = CConfig::getLinks($conf->getLinks(), "postCourse");
     // initialize lURL
     $this->lURL = $this->query->getAddress();
     //POST AddCourse
     $this->app->post('/' . $this->getPrefix() . '(/)', array($this, 'AddCourse'));
     //PUT EditCourse
     $this->app->put('/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'editCourse'));
     //DELETE DeleteCourse
     $this->app->delete('/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'deleteCourse'));
     //POST AddCourseMember
     $this->app->post('/' . $this->getPrefix() . '/course/:courseid/user/:userid/status/:status(/)', array($this, 'addCourseMember'));
     //GET GetCourseMember
     $this->app->get('/' . $this->getPrefix() . '/course/:courseid/user(/)', array($this, 'getCourseMember'));
     //GET GetCourses
     $this->app->get('/' . $this->getPrefix() . '/user/:userid(/)', array($this, 'getCourses'));
     //run Slim
     $this->app->run();
 }
예제 #4
0
 /**
  * the component constructor
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(CControl::getPrefix() . ',link,definition', dirname(__FILE__));
     // runs the DBSubmission
     if ($com->used()) {
         return;
     }
     // initialize slim
     $this->_app = new \Slim\Slim();
     $this->_app->response->headers->set('Content-Type', 'application/json');
     // POST AddPlatform
     $this->_app->post('/platform', array($this, 'addPlatform'));
     // DELETE DeletePlatform
     $this->_app->delete('/platform', array($this, 'deletePlatform'));
     // GET GetExistsPlatform
     $this->_app->get('/link/exists/platform', array($this, 'getExistsPlatform'));
     // GET GetTableReferences
     $this->_app->get('/tableReferences', array($this, 'getTableReferences'));
     // PUT EditLink
     $this->_app->put('/link/:linkid(/)', array($this, 'editLink'));
     // DELETE DeleteLink
     $this->_app->delete('/link/:linkid(/)', array($this, 'deleteLink'));
     // POST SetLink
     $this->_app->post('/link(/)', array($this, 'setLink'));
     // GET GetLink
     $this->_app->get('/link/:linkid(/)', array($this, 'getLink'));
     // PUT EditComponent
     $this->_app->put('/component/:componentid(/)', array($this, 'editComponent'));
     // DELETE DeleteComponent
     $this->_app->delete('/component/:componentid(/)', array($this, 'deleteComponent'));
     // POST SetComponent
     $this->_app->post('/component(/)', array($this, 'setComponent'));
     // GET GetComponent
     $this->_app->get('/component/:componentid(/)', array($this, 'getComponent'));
     // GET GetComponentDefinitions
     $this->_app->get('/definition(/)', array($this, 'getComponentDefinitions'));
     // GET SendComponentDefinitions
     $this->_app->get('(/definition)/send(/)', array($this, 'sendComponentDefinitions'));
     // GET GetComponentDefinition
     $this->_app->get('/definition/:componentid(/)', array($this, 'getComponentDefinition'));
     // run Slim
     $this->_app->run();
 }
예제 #5
0
 /**
  * REST actions
  *
  * This function contains the REST actions with the assignments to
  * the functions.
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(DBForm::getPrefix() . ',course,link', dirname(__FILE__));
     // runs the DBForm
     if ($com->used()) {
         return;
     }
     $conf = $com->loadConfig();
     // initialize component
     $this->_conf = $conf;
     $this->query = array(CConfig::getLink($conf->getLinks(), 'out'));
     // initialize slim
     $this->_app = new \Slim\Slim();
     $this->_app->response->headers->set('Content-Type', 'application/json');
     // POST AddCourse
     $this->_app->post('/course(/)', array($this, 'addCourse'));
     // POST DeleteCourse
     $this->_app->delete('/course/:courseid(/)', array($this, 'deleteCourse'));
     // PUT EditForm
     $this->_app->put('/' . $this->getPrefix() . '(/form)/:formid(/)', array($this, 'editForm'));
     // DELETE DeleteForm
     $this->_app->delete('/' . $this->getPrefix() . '(/form)/:formid(/)', array($this, 'deleteForm'));
     // POST AddForm
     $this->_app->post('/' . $this->getPrefix() . '(/)', array($this, 'addForm'));
     // GET GetForm
     $this->_app->get('/' . $this->getPrefix() . '(/form)/:formid(/)', array($this, 'getForm'));
     // GET GetCourseForms
     $this->_app->get('/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'getCourseForms'));
     // GET GetExistsCourseForms
     $this->_app->get('/link/exists/course/:courseid(/)', array($this, 'getExistsCourseForms'));
     // GET GetSheetForms
     $this->_app->get('/' . $this->getPrefix() . '/exercisesheet/:esid(/)', array($this, 'getSheetForms'));
     // GET GetExerciseForms
     $this->_app->get('/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'getExerciseForms'));
     // run Slim
     $this->_app->run();
 }
예제 #6
0
 /**
  * REST actions
  *
  * This function contains the REST actions with the assignments to
  * the functions.
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(DBChoice::getPrefix() . ',course,link', dirname(__FILE__));
     // runs the DBChoice
     if ($com->used()) {
         return;
     }
     // initialize component
     $this->_conf = $com;
     // initialize slim
     $this->_app = new \Slim\Slim(array('debug' => true));
     $this->_app->response->headers->set('Content-Type', 'application/json');
     // POST AddCourse
     $this->_app->post('(/:preChoice(/:preForm(/:preExercise)))/course', array($this, 'addCourse'));
     // DELETE DeleteCourse
     $this->_app->delete('(/:preChoice(/:preForm(/:preExercise)))/course(/course)/:courseid', array($this, 'deleteCourse'));
     // PUT EditChoice
     $this->_app->put('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '(/choice)/:choiceid(/)', array($this, 'editChoice'));
     // DELETE DeleteChoice
     $this->_app->delete('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '(/choice)/:choiceid(/)', array($this, 'deleteChoice'));
     // POST AddChoice
     $this->_app->post('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '(/)', array($this, 'addChoice'));
     // GET GetChoice
     $this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '(/choice)/:choiceid(/)', array($this, 'getChoice'));
     // GET GetCourseChoices
     $this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'getCourseChoices'));
     // GET GetExistsCourseChoices
     $this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/link/exists/course/:courseid(/)', array($this, 'getExistsCourseChoices'));
     // GET GetSheetChoices
     $this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '/exercisesheet/:esid(/)', array($this, 'getSheetChoices'));
     // GET GetExerciseChoices
     $this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'getExerciseChoices'));
     // GET GetFormChoices
     $this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '/form/:formid(/)', array($this, 'getFormChoices'));
     // run Slim
     $this->_app->run();
 }
예제 #7
0
 /**
  * REST actions
  *
  * This function contains the REST actions with the assignments to
  * the functions.
  *
  * @param Component $conf component data
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(DBAttachment::getPrefix(), dirname(__FILE__));
     // runs the DBAttachment
     if ($com->used()) {
         return;
     }
     $conf = $com->loadConfig();
     // initialize component
     $this->_conf = $conf;
     $this->query = array(CConfig::getLink($conf->getLinks(), 'out'));
     $this->query2 = array(CConfig::getLink($conf->getLinks(), 'out2'));
     // initialize slim
     $this->_app = new \Slim\Slim();
     $this->_app->response->setStatus(409);
     $this->_app->response->headers->set('Content-Type', 'application/json');
     // POST AddPlatform
     $this->_app->post('/platform', array($this, 'addPlatform'));
     // DELETE DeletePlatform
     $this->_app->delete('/platform', array($this, 'deletePlatform'));
     // GET GetExistsPlatform
     $this->_app->get('/link/exists/platform', array($this, 'getExistsPlatform'));
     // PUT EditAttachment
     $this->_app->put('/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'editAttachment'));
     // DELETE DeleteAttachment
     $this->_app->delete('/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'deleteAttachment'));
     // DELETE DeleteExerciseAttachments
     $this->_app->delete('/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'deleteExerciseAttachment'));
     // DELETE DeleteExerciseFileAttachment
     $this->_app->delete('/' . $this->getPrefix() . '/exercise/:eid/file/:fileid(/)', array($this, 'deleteExerciseFileAttachment'));
     // POST AddAttachment
     $this->_app->post('/' . $this->getPrefix() . '(/)', array($this, 'addAttachment'));
     // GET GetAttachment
     $this->_app->get('/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'getAttachment'));
     // GET GetAllAttachments
     $this->_app->get('/' . $this->getPrefix() . '(/attachment)(/)', array($this, 'getAllAttachments'));
     // GET GetExerciseAttachments
     $this->_app->get('/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'getExerciseAttachments'));
     // GET GetSheetAttachments
     $this->_app->get('/' . $this->getPrefix() . '/exercisesheet/:esid(/)', array($this, 'getSheetAttachments'));
     // run Slim
     $this->_app->run();
 }
예제 #8
0
파일: bootstrap.php 프로젝트: Jud/Slim
//Sample POST route for PHP >=5.3
Slim::post('/post', function () {
    echo '<p>Here are the details about your POST request:</p>';
    print_r(Slim::request());
});
//Sample POST route for PHP <5.3
/*
Slim::post('/post', 'post_example');
function post_example() {
	echo '<br/><br/>Here are the details about your POST request:<br/><br/>';
	print_r(Slim::request());
}
*/
//Sample PUT route for PHP >=5.3
Slim::put('/put', function () {
    echo '<p>Here are the details about your PUT request:</p>';
    print_r(Slim::request());
});
//Sample PUT route for PHP <5.3
/*
Slim::put('/put', 'put_example');
function put_example() {
	echo '<br/><br/>Here are the details about your PUT request:<br/><br/>';
	print_r(Slim::request());
}
*/
//Sample DELETE route for PHP >=5.3
Slim::delete('/delete', function () {
    echo '<p>Here are the details about your DELETE request:</p>';
    print_r(Slim::request());
});
//Sample DELETE route for PHP <5.3
    } else {
        echo json_encode(array("status" => false, "message" => "Book ID {$id} does not exist"));
    }
});
$app->post("/book", function () use($app, $db) {
    $app->response()->header("Content-Type", "application/json");
    $book = $app->request()->post();
    $result = $db->books->insert($book);
    echo json_encode(array("id" => $result["id"]));
});
$app->put("/book/:id", function ($id) use($app, $db) {
    $app->response()->header("Content-Type", "application/json");
    $book = $db->books()->where("id", $id);
    if ($book->fetch()) {
        $post = $app->request()->put();
        $result = $book->update($post);
        echo json_encode(array("status" => (bool) $result, "message" => "Book updated successfully"));
    } else {
        echo json_encode(array("status" => false, "message" => "Book id {$id} does not exist"));
    }
});
$app->delete("/book/:id", function ($id) use($app, $db) {
    $app->response()->header("Content-Type", "application/json");
    $book = $db->books()->where("id", $id);
    if ($book->fetch()) {
        $result = $book->delete();
        echo json_encode(array("status" => true, "message" => "Book deleted successfully"));
    } else {
        echo json_encode(array("status" => false, "message" => "Book id {$id} does not exist"));
    }
});
<?php

require 'Slim/Slim.php';
$app = new Slim();
$app->get('/items', 'getItems');
$app->get('/items/:id', 'getItem');
$app->get('/items/search/:query', 'findByName');
$app->post('/items', 'addItem');
$app->put('/items/:id', 'updateItem');
$app->delete('/items/:id', 'deleteItem');
$app->run();
function getItems()
{
    $sql = "select * FROM item ORDER BY name";
    try {
        $db = getConnection();
        $stmt = $db->query($sql);
        $items = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        // echo '{"items": ' . json_encode($items) . '}';
        echo json_encode($items);
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
function getItem($id)
{
    $sql = "SELECT * FROM item WHERE id=:id";
    try {
        $db = getConnection();
        $stmt = $db->prepare($sql);
예제 #11
0
파일: index.php 프로젝트: ceroberoz/kurs
                <h2>Slim Framework Extras</h2>
                <p>
                    Custom View classes for Smarty, Twig, Mustache, and other template
                    frameworks are available online in a separate repository.
                </p>
                <p><a href="https://github.com/codeguy/Slim-Extras" target="_blank">Browse the Extras Repository</a></p>
            </section>
        </body>
    </html>
EOT;
    echo $template;
});
//POST route
$app->post('/post', function () {
    echo 'This is a POST route';
});
//PUT route
$app->put('/put', function () {
    echo 'This is a PUT route';
});
//DELETE route
$app->delete('/delete', function () {
    echo 'This is a DELETE route';
});
/**
 * Step 4: Run the Slim application
 *
 * This method should be called last. This is responsible for executing
 * the Slim application using the settings and routes defined above.
 */
$app->run();
예제 #12
0
<?php

set_include_path(implode(PATH_SEPARATOR, array(realpath(dirname(__FILE__) . '/library'), get_include_path())));
require_once 'Slim/Slim.php';
require_once 'controller/ProdutosController.php';
$app = new Slim();
$pcontroller = new ProdutosController();
$app->get('/produtos', function () use($pcontroller) {
    echo json_encode($pcontroller->listarProdutos());
});
$app->post('/produtos', function () use($pcontroller, $app) {
    $produto = json_decode(file_get_contents("php://input"));
    echo json_encode($pcontroller->salvarProduto($produto));
});
$app->put('/produtos', function () use($pcontroller, $app) {
    $produto = $app->request()->put();
    unset($produto['$$hashKey']);
    echo json_encode($pcontroller->atualizarProduto($produto));
});
$app->delete('/produtos/:id', function ($id) use($pcontroller) {
    echo $pcontroller->removerProduto($id);
});
$app->run();
예제 #13
0
<?php

require 'Slim/Slim.php';
$app = new Slim();
$app->get('/users', 'getUsers');
$app->post('/users', 'addUser');
$app->get('/users/:id', 'getUser');
$app->get('/users/search/:query', 'findByName');
$app->put('/users/:id', 'updateUser');
$app->delete('/users/:id', 'deleteUser');
$app->run();
function getConnection()
{
    $dbhost = "127.0.0.1";
    $dbuser = "******";
    $dbpass = "******";
    $dbname = "angular-mysql";
    $dbh = new PDO("mysql:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass);
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    return $dbh;
}
function getUsers()
{
    $sql = "select * FROM users ORDER BY id";
    try {
        $db = getConnection();
        $stmt = $db->query($sql);
        $users = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        echo json_encode($users);
    } catch (PDOException $e) {
예제 #14
0
<?php

require 'Slim/Slim.php';
$app = new Slim();
$app->get('/wines', 'getWines');
$app->get('/wines/:id', 'getWine');
$app->get('/wines/search/:query', 'findByName');
$app->post('/wines', 'addWine');
$app->put('/wines/:id', 'updateWine');
$app->delete('/wines/:id', 'deleteWine');
$app->run();
function getWines()
{
    $sql = "select * FROM wine ORDER BY name";
    try {
        $db = getConnection();
        $stmt = $db->query($sql);
        $wines = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        // echo '{"wine": ' . json_encode($wines) . '}';
        echo json_encode($wines);
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
function getWine($id)
{
    $sql = "SELECT * FROM wine WHERE id=:id";
    try {
        $db = getConnection();
        $stmt = $db->prepare($sql);
예제 #15
0
<?php

require 'Slim/Slim.php';
$app = new Slim();
$app->get('/beers', 'getBeers');
$app->get('/beers/:id', 'getBeer');
$app->get('/beers/search/:query', 'findByName');
$app->post('/beers', 'addBeer');
$app->put('/beers/:id', 'updateBeer');
$app->delete('/beers/:id', 'deleteBeer');
$app->run();
function getBeers()
{
    $sql = "select * FROM wine ORDER BY name";
    try {
        $db = getConnection();
        $stmt = $db->query($sql);
        $beers = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        // echo '{"wine": ' . json_encode($beers) . '}';
        echo json_encode($beers);
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
function getBeer($id)
{
    $sql = "SELECT * FROM wine WHERE id=:id";
    try {
        $db = getConnection();
        $stmt = $db->prepare($sql);
예제 #16
0
파일: SlimTest.php 프로젝트: ntdt/Slim
 /**
  * Test Slim sets PUT route
  *
  * Pre-conditions:
  * You have initialized a Slim app with a PUT route.
  *
  * Post-conditions:
  * The PUT route is returned, and its pattern and
  * callable are set correctly.
  */
 public function testSlimPutRoute(){
     Slim::init();
     $callable = function () { echo "foo"; };
     $route = Slim::put('/foo/bar', $callable);
     $this->assertEquals('/foo/bar', $route->getPattern());
     $this->assertSame($callable, $route->getCallable());
 }
예제 #17
0
require 'service/cart.php';
require 'service/qrcode.php';
require 'service/icon.php';
require 'service/dashboard.php';
require 'service/cart_cron.php';
require_once 'service/voucher_pdf.php';
require_once 'service/merchantrestaurants.php';
require_once 'service/merchantoutlet.php';
require_once 'service/merchantmenucategory.php';
$app = new Slim();
$app->config('debug', true);
$app->get('/wines', 'getWines');
$app->get('/wines/:id', 'getWine');
$app->get('/wines/search/:query', 'findByName');
$app->post('/wines', 'addWine');
$app->put('/wines/:id', 'updateWine');
$app->delete('/wines/:id', 'deleteWine');
/***************** Users ************/
$app->post('/users', 'addUser');
$app->post('/users/login', 'getlogin');
$app->post('/users/forgotPass', 'getforgetPass');
$app->post('/users/changePassword', 'changePassword');
$app->put('/users/:id', 'updateUser');
$app->put('/users/activeProfile/:id', 'activeProfile');
$app->get('/users', 'getAllUsers');
$app->get('/user/:id', 'getUser');
$app->post('/users/logout', 'getlogout');
$app->delete('/users/:id', 'deleteUser');
$app->get('/getAllMerchants', 'getAllMerchants');
$app->get('/getCustomer/:id', 'getCustomer');
$app->get('/getAllCustomers', 'getAllCustomers');
예제 #18
0
<?php

require 'Slim/Slim.php';
$app = new Slim();
//restful actions
//when the slim app receives a get/post/put/delete the relevant function is called
$app->get('/films', 'getFilms');
$app->get('/films/:id', 'getFilm');
$app->get('/films/search/:query', 'findByName');
$app->post('/films', 'addFilm');
$app->put('/films/:id', 'updateFilm');
$app->delete('/films/:id', 'deleteFilm');
$app->run();
function getFilms()
{
    $sql = "select * FROM film ORDER BY title";
    try {
        $db = getConnection();
        $stmt = $db->query($sql);
        $films = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        echo '{"film": ' . json_encode($films) . '}';
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
function getFilm($id)
{
    $sql = "SELECT * FROM film WHERE id=:id";
    try {
        $db = getConnection();
예제 #19
0
파일: index.php 프로젝트: einnor/mailroom
//Users
$app->post('/users', 'createUser');
//Done
$app->get('/users/all', 'getAllUsers');
//Done
$app->get('/users/common', 'getAllCommonUsers');
//Done
$app->get('/users/mailroom', 'getAllMailroomUsers');
//Done
$app->get('/users/admin', 'getAllAdminUsers');
//Done
//Mail
//$app->get('/mails/all','getAllMail');//Done
$app->post('/mails', 'submitMail');
//Done
$app->put('/mails/:id', 'updateMail');
//Done
$app->put('/mails/state/:id', 'changeState');
//Done
$app->put('/mails/recipient/confirm', 'confirmReceived');
//Done
$app->get('/mails/state/:id', 'getState');
$app->delete('/mails/:id', 'deleteMail');
//Done
$app->get('/mails/track/:id', 'trackMail');
//Done
$app->get('/mails/:id', 'getMailDetails');
//Done
$app->get('/mails/code/:id', 'getMailDetailsByCode');
//Done
//Tracker 1.Submitted
예제 #20
0
파일: index.php 프로젝트: jacoobwang/ecp
 * 更新CP列表
 */
$app->put('/require/cp', function () use($app) {
    $req_data = $app->request()->put();
    $display_order = $req_data['require'];
    //echo '===11==';
    //dump($display_order);
    $ids = implode(',', array_keys($display_order));
    $sql = "UPDATE tb_require SET require_cp_id = CASE require_id ";
    foreach ($display_order as $id => $ordinal) {
        $sql .= sprintf("WHEN %d THEN %d ", $id, $ordinal);
    }
    $sql .= "END, require_state =  CASE require_id ";
    foreach ($display_order as $id => $ordinal) {
        $sql .= sprintf("WHEN %d THEN 2 ", $id);
    }
    $sql .= " END WHERE require_id IN ({$ids})";
    //echo '==='.$sql;
    try {
        $db = getConnection();
        $stmt = $db->prepare($sql);
        $stmt->execute();
        $db = null;
        echo '{"require":' . json_encode($display_order) . '}';
        elog(" put require cp success. msg = " . json_encode($display_order));
    } catch (PDOException $e) {
        echo '{"error":{"text":"' . $e->getMessage() . '"}}';
        elog(" put require cp error. data = " . json_encode($display_order) . " msg = " . $e->getMessage(), 'error');
    }
});
/**
 * 根据ID 修改需求
예제 #21
0
<?php

require dirname(__FILE__) . '/../Slim/Slim.php';
$app = new Slim();
$app->get("/", "getStores");
$app->get("/:id", "getStore");
$app->get("/search/:query", "findByName");
$app->post("/", "addStore");
$app->put("/:id", "updateStore");
$app->delete("/:id", "deleteStore");
$app->run();
function getStores()
{
    $sql = "select * FROM store ORDER BY name";
    try {
        $db = getConnection();
        $stmt = $db->query($sql);
        $stores = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        // echo '{"wine": ' . json_encode($wines) . '}';
        echo json_encode($stores);
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
function getStore($id)
{
    $sql = "SELECT * FROM store WHERE id=:id";
    try {
        $db = getConnection();
        $stmt = $db->prepare($sql);
예제 #22
0
<?php

require 'Slim/Slim.php';
require '../site/functions.php';
$app = new Slim();
$app->get('/accomplishment/:id', 'GetAccomplishment');
$app->get('/allaccomplishment/:id', 'GetAllAccomplishments');
$app->get('/accomplishment/search/:query', 'FinaByAccomplishment');
$app->post('/accomplishment', 'InsertAccomplishment');
$app->put('/accomplishment/:id', 'UpdateAccomplishment');
$app->delete('/accomplishment/:id', 'DeleteAccomplishment');
$app->get('/accomplishment/title/:keyword', 'getTitlesFromCache');
$app->get('/accomplishment/alltitle', 'getAllTitles');
$app->run();
// Generate Guid
function NewGuid()
{
    $s = strtoupper(md5(uniqid(rand(), true)));
    $guidText = substr($s, 0, 8) . substr($s, 8, 4) . substr($s, 12, 4) . substr($s, 16, 4) . substr($s, 20);
    return $guidText;
}
// End Generate Guid
function getWines()
{
    $sql = "select * FROM wine ORDER BY name";
    try {
        $db = getConnection();
        $stmt = $db->query($sql);
        $wines = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        echo '{"wine": ' . json_encode($wines) . '}';
예제 #23
0
<?php

session_start();
require 'Business/PatientData.php';
require 'Business/DoctorData.php';
require 'Business/StaffData.php';
require 'Business/MasterData.php';
require 'Slim/Slim.php';
$app = new Slim();
error_reporting(E_ALL);
ini_set("log_errors", true);
ini_set("error_log", "/Applications/MAMP/htdocs/HealthCareSystem/RestAPI/errorlog.log");
$app->get('/authenticate/:username/:password', 'authenticateUser');
$app->get('/', 'initialMessage');
$app->post('/registerUser', 'registerUser');
$app->put('/updateprofile/:id', 'updateProfile');
$app->get('/appointmentsList/:hosiptal/:doctor/:appdate', 'appointmentsList');
$app->post('/createAppointment', 'createAppointment');
$app->get('/hosiptalDoctorData', 'hosiptalDoctorData');
$app->get('/professionBasedData/:profession/:name', 'professionBasedData');
$app->get('/doctorMasterData/:doctorId', 'doctorMasterData');
$app->get('/userMasterData/:userId', 'userMasterData');
$app->post('/createUser', 'createUser');
$app->get('/patientList/:patientName', 'patientList');
$app->get('/appointmentPatientList/:patientName/:hosiptal/:appdate', 'appointmentPatientList');
$app->put('/updateAppointment/:appointmentId', 'updateAppointment');
$app->run();
function initialMessage()
{
    try {
        //echo "<h1>Hello Slim World</h1>";
예제 #24
0
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_connections(array('development' => 'mysql://root:@localhost/todos'));
});
$app = new Slim();
function reqBody()
{
    global $app;
    return json_decode($app->request()->getBody(), true);
}
$app->get('/json', function () {
    echo json_encode(array_map(function ($todo) {
        return $todo->attributes();
    }, Todo::all()));
});
$app->post('/json', function () {
    $todo = new Todo(reqBody());
    $todo->save();
});
$app->get('/json/:id', function ($id) {
    echo Todo::find($id)->to_json();
});
$app->put('/json/:id', function ($id) {
    Todo::find($id)->update_attributes(reqBody());
});
$app->delete('/json/:id', function ($id) {
    Todo::find($id)->delete();
});
$app->get('/', function () {
    echo file_get_contents('index.html');
});
$app->run();
예제 #25
0
$app->get('/users/search/:name', function ($name) use($user) {
    $user->getByName($name);
});
$app->delete('/users/:id', function ($id) use($user) {
    $user->delete($id);
});
$app->post('/users', function () use($user, $app) {
    $request = $app->request();
    $body = $request->getBody();
    $vo = json_decode($body);
    $user->insert($vo);
});
$app->put('/users/:id', function ($id) use($user, $app) {
    $request = $app->request();
    $body = $request->getBody();
    $vo = json_decode($body);
    $vo->facebook_user_id = $id;
    $user->update($vo);
});
$app->put('/users/:id/score', function ($id) use($user, $app) {
    $request = $app->request();
    $body = $request->getBody();
    $vo = json_decode($body);
    $vo->facebook_user_id = $id;
    $user->updateScore($vo);
    $user->updatePlayerRewards($id, $vo->game_score, $vo->score);
});
$app->put('/users/:id/friends', function ($id) use($user, $app) {
    $request = $app->request();
    $body = $request->getBody();
    $vo = json_decode($body);
예제 #26
0
파일: users.php 프로젝트: octobloc/backhome
// Access-Control headers are received during OPTIONS requests
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) {
        header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
    }
    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
        header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
    }
    exit(0);
}
include 'Slim/Slim.php';
$app = new Slim();
$app->post('/login', 'userLogin');
$app->post('/join', 'userJoin');
$app->delete('/user', 'deleteUser');
$app->put('/user', 'updateUser');
$app->get('/user', 'getUser');
$app->get('/user/:id', 'getUser');
//INCOMPLETE:
//$app->post('/users/search', 'findByParameter');
$app->run();
function userLogin()
{
    $request = Slim::getInstance()->request();
    $user = json_decode($request->getBody());
    //Get Salt
    $sql = "SELECT\n\n        salt\n\n        FROM users WHERE username=:username LIMIT 1";
    try {
        $db = getConnection();
        $stmt = $db->prepare($sql);
        $stmt->bindParam("username", $user->username);
예제 #27
0
파일: index.php 프로젝트: artemklv/shelfari
<?php

require "includes/index.php";
require_once "Slim/Slim.php";
$data = new Slim();
$data->get('/books/search', function () use($data) {
    $query = $data->request()->params('name');
    findByName($query);
});
$data->get('/books', 'getBooks');
$data->get('/books/:id', 'getBook');
//$data->get('/books/search:query', 'findByName');
$data->post('/books', 'addBook');
$data->put('/books/:id', 'updateBook');
$data->delete('/books/:id', 'deleteBook');
$data->run();
function getBooks()
{
    $sql = "select * FROM books ORDER BY id DESC";
    try {
        $db = getConnection();
        $stmt = $db->query($sql);
        $books = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        echo json_encode($books);
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
function getBook($id)
{
예제 #28
0
<?php

require 'Slim/Slim.php';
require 'conexion.php';
$app = new Slim();
$app->get('/medicos', 'obtenerMedicos');
$app->get('/medicos/:id', 'obtenerMedico');
$app->post('/agregar_medico', 'agregarMedico');
$app->put('/medicos/:id', 'editarMedico');
$app->delete('/medicos/:id', 'eliminarMedico');
$app->get('/especialidades', 'obtenerEspecialidades');
$app->get('/especialidades/:id', 'obtenerEspecialidad');
$app->post('/agregar_especialidad', 'agregarEspecialidad');
$app->put('/especialidades/:id', 'editarEspecialidad');
$app->delete('/especialidades/:id', 'eliminarEspecialidad');
$app->get('/medicosespecialidades/:id', 'obtenerMedicoEspecialidades');
$app->post('/agregar_medicoespecialidad/:id', 'agregarMedicoEspecialidad');
$app->run();
function obtenerMedicos()
{
    $sql = "select idMedico,CONCAT(Nombre,' ',Apellido) Nombre FROM medico where Estado=1 ORDER BY Nombre";
    try {
        $db = getConnection();
        $stmt = $db->query($sql);
        $wines = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        echo json_encode($wines);
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
예제 #29
0
<?php

require 'Slim/Slim.php';
$app = new Slim();
$app->get('/new-events', 'listNewEvents');
$app->put('/ack-event/:id', 'acknowledgeEvent');
$app->run();
function listNewEvents()
{
    $sql = "SELECT event_id, user_id, wf_id, event_msg FROM events WHERE event_status=0 ORDER BY event_id";
    try {
        $dbT = getConnt();
        $stmt = $dbT->query($sql);
        $wines = $stmt->fetchAll(PDO::FETCH_OBJ);
        $dbT = null;
        echo json_encode($wines);
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
function acknowledgeEvent($id)
{
    //$eid = $request->params('eid');
    $sql = "UPDATE `events` SET event_status=2 WHERE event_id=:id";
    try {
        //$dbT = getConnection();
        $dbT = getConnt();
        $stmt = $dbT->prepare($sql);
        //$stmt->bindParam("id", $eid)
        $stmt->bindParam("id", $id);
        $stmt->execute();
예제 #30
0
파일: SlimTest.php 프로젝트: rs3d/Slimplr
 /**
  * Test PUT route
  */
 public function testPutRoute()
 {
     Slim_Environment::mock(array('REQUEST_METHOD' => 'PUT', 'SCRIPT_NAME' => '/foo', 'PATH_INFO' => '/bar'));
     $s = new Slim();
     $mw1 = function () {
         echo "foo";
     };
     $mw2 = function () {
         echo "bar";
     };
     $callable = function () {
         echo "xyz";
     };
     $route = $s->put('/bar', $mw1, $mw2, $callable);
     $s->call();
     $this->assertEquals('foobarxyz', $s->response()->body());
     $this->assertEquals('/bar', $route->getPattern());
     $this->assertSame($callable, $route->getCallable());
 }