<?php chdir(__DIR__ . '/../../../'); ini_set('session.use_cookies', 0); require 'vendor/autoload.php'; \Caco\MiniAR::setDefaultPdo($pdo = new \PDO('sqlite:database/app.sqlite3')); $pdo->exec('PRAGMA foreign_keys = ON'); $app = new \Slim\Slim(); $app->view(new \Caco\Slim\JsonView()); $app->add($auth = new \Caco\Slim\Auth\Basic()); $auth->setRealm('Caco Cloud'); $app->group('/password', function () use($app) { $app->get('/:key/:id', '\\Caco\\Password\\REST:one')->conditions(['id' => '\\d+']); $app->get('/:key', '\\Caco\\Password\\REST:all'); $app->post('/:key', '\\Caco\\Password\\REST:add'); $app->delete('/:key/:id', '\\Caco\\Password\\REST:delete')->conditions(['id' => '\\d+']); $app->put('/:key/:id', '\\Caco\\Password\\REST:edit')->conditions(['id' => '\\d+']); }); $app->group('/bookmark', function () use($app) { $app->get('/:id', '\\Caco\\Bookmark\\REST:one')->conditions(['id' => '\\d+']); $app->get('', '\\Caco\\Bookmark\\REST:all'); $app->post('', '\\Caco\\Bookmark\\REST:add'); $app->delete('/:id', '\\Caco\\Bookmark\\REST:delete')->conditions(['id' => '\\d+']); $app->put('/:id', '\\Caco\\Bookmark\\REST:edit')->conditions(['id' => '\\d+']); }); $app->group('/config', function () use($app) { $app->get('/:key', '\\Caco\\Config\\REST:one'); $app->get('', '\\Caco\\Config\\REST:all'); $app->post('', '\\Caco\\Config\\REST:add'); $app->delete('/:key', '\\Caco\\Config\\REST:delete'); $app->put('/:key', '\\Caco\\Config\\REST:edit');
/** * Gets a list of all data fields. * * @return array */ protected function getFields() { $fields = parent::getFields(); unset($fields['unread']); unset($fields['total']); unset($fields['outdated']); return $fields; }
<?php if (PHP_SAPI !== 'cli') { die('This is a cli!'); } require __DIR__ . '/../vendor/autoload.php'; \Caco\MiniAR::setDefaultPdo($pdo = new \PDO('sqlite:' . __DIR__ . '/../database/app.sqlite3')); $pdo->exec('PRAGMA foreign_keys = ON'); $opts = getopt('c:', ['cli:']); $cliClassName = empty($opts['c']) ? $opts['cli'] : $opts['c']; /** @var Caco\CLI\ICLI $cliClass */ $cliClass = new $cliClassName(); if (!$cliClass instanceof Caco\CLI\ICLI) { die('Given class is not a cli!'); } $cliClass->init(); try { exit($cliClass->run()); } catch (InvalidArgumentException $e) { echo $e->getMessage() . PHP_EOL; }
public function __construct(\PDO $pdo = null) { parent::__construct($pdo); $this->inserted = time(); }
/** * Gets a list of all data fields. * * @return array */ protected function getFields() { $fields = parent::getFields(); unset($fields['queued']); return $fields; }