added some development tools
[windows-sources.git] / developer / Samples / Bot / getbots.php
blob7526be4db394680f57d30832418161f108995786
1 <?php
2 /***************************************
3 * http://www.program-o.com
4 * PROGRAM O
5 * Version: 2.5.3
6 * FILE: getbots.php
7 * AUTHOR: Elizabeth Perreau and Dave Morton
8 * DATE: MAY 17TH 2014
9 * DETAILS: Searches the database for all active chatbots, returning a JSON encoded array of ID/name pairs
10 ***************************************/
12 $time_start = microtime(true);
13 $script_start = $time_start;
14 $last_timestamp = $time_start;
15 $thisFile = __FILE__;
16 require_once("config/global_config.php");
17 //load shared files
18 require_once(_LIB_PATH_ . 'PDO_functions.php');
19 include_once (_LIB_PATH_ . "error_functions.php");
20 include_once(_LIB_PATH_ . 'misc_functions.php');
21 ini_set('error_log', _LOG_PATH_ . 'getbots.error.log');
23 $dbConn = db_open();
24 $sql = "select `bot_id`, `bot_name` from `$dbn`.`bots`;";
25 $result = db_fetchAll($sql, null, __FILE__, __FUNCTION__, __LINE__);
26 $bots = array('bots'=>array());
27 foreach ($result as $row)
29 $bot_id = $row['bot_id'];
30 $bot_name = $row['bot_name'];
31 $bots['bots'][$bot_id] = $bot_name;
33 header('Content-type: application/json');
34 $out = json_encode($bots);
35 exit($out);