From 960d0a8ac65198f747eebed867f51f2ba6a3b008 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 28 Jul 2014 09:34:23 +0200 Subject: add a page to be able to retrieve a table content --- get.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 get.php diff --git a/get.php b/get.php new file mode 100644 index 0000000..afcde43 --- /dev/null +++ b/get.php @@ -0,0 +1,64 @@ +. + * + * @category Main + * @package RPMPHP + * + * @author Remi Collet + * @author Johan Cwiklinski + * @copyright 2010-2014 Remi Collet + * @license http://www.gnu.org/licenses/agpl-3.0-standalone.html AGPL License 3.0 or (at your option) any later version + * @link http://github.com/remicollet/rpmphp/ + * @since The begining of times. +*/ +chdir(dirname($_SERVER["SCRIPT_FILENAME"])); +date_default_timezone_set('Europe/Paris'); + +if (!isset($_GET['table'])) { + die("Missing arg"); +} +require "include/main.php"; +require "class/CommonTable.php"; + +try { + $db = new PDO ("mysql:dbname=" . MYBASE . ";host=" . MYHOST, MYUSER, MYPASS); + + $result = array(); + switch ($_GET['table']) { + case 'packagist': + $pkgist = new TablePackagist($db); + foreach($pkgist->request(array('ORDER'=>'rpmname')) as $rec) { + $result[$rec['pkgname']] = $rec['rpmname']; + } + break; + default: + die("Invalid arg"); + } + echo json_encode($result, JSON_PRETTY_PRINT); + +} catch(PDOException $e) { + printf("%s ERREUR : %s\n", date("r"), $e->getMessage()); +} -- cgit