* -----------------------------------------------------------------------------------------------*/ $app = new Slim(array('log.enabled' => true, 'templates.path' => '../templates')); /* ------------------------------------------------------------------------------------------------ * Configuration * -----------------------------------------------------------------------------------------------*/ $provider = new ArrayProvider('../config'); $config = new Container($provider); // Environment Selection $app->configureMode('development', function () use($config) { $config->setEnvironment('development'); }); $config->load(array('opentok', 'redis'), true); /* ------------------------------------------------------------------------------------------------ * OpenTok Initialization * -----------------------------------------------------------------------------------------------*/ $opentok = new OpenTok($config->opentok('key'), $config->opentok('secret')); /* ------------------------------------------------------------------------------------------------ * Redis Initialization * -----------------------------------------------------------------------------------------------*/ $redis = new \Predis\Client($config->redis(), array('prefix' => $config->redis('prefix'))); define('PREFIX_HELP_SESSION_KEY', 'helpsession:'); define('HELP_QUEUE_KEY', 'helpqueue'); /* ------------------------------------------------------------------------------------------------ * Routing * -----------------------------------------------------------------------------------------------*/ // Customer landing page $app->get('/', function () use($app) { $app->render('customer.php'); }); // Representative landing page $app->get('/agente', function () use($app) {
/* ------------------------------------------------------------------------------------------------ * Configuration * -----------------------------------------------------------------------------------------------*/ $provider = new ArrayProvider('../config'); $config = new Container($provider); // Environment Selection $app->configureMode('development', function () use($config) { $config->setEnvironment('development'); }); $config->load(array('opentok'), true); // Constants define('NAME_MAX_LENGTH', '100'); /* ------------------------------------------------------------------------------------------------ * OpenTok Initialization * -----------------------------------------------------------------------------------------------*/ $opentok = new OpenTok($config->opentok('key'), $config->opentok('secret')); /* ------------------------------------------------------------------------------------------------ * Routing * -----------------------------------------------------------------------------------------------*/ // Presence configuration // // Response: (JSON encoded) // * `apiKey`: The presence session API Key // * `sessionId`: The presence session ID $app->get('/presence', function () use($app, $config) { $responseData = array('apiKey' => $config->opentok('key'), 'sessionId' => $config->opentok('presenceSession')); $app->response->headers->set('Content-Type', 'application/json'); $app->response->setBody(json_encode($responseData)); }); // User enters //
* -----------------------------------------------------------------------------------------------*/ $app = new Slim(array('log.enabled' => true, 'templates.path' => '../templates')); /* ------------------------------------------------------------------------------------------------ * Configuration * -----------------------------------------------------------------------------------------------*/ $provider = new ArrayProvider('../config'); $config = new Container($provider); // Environment Selection $app->configureMode('development', function () use($config) { $config->setEnvironment('development'); }); $config->load(array('opentok', 'mysql'), true); /* ------------------------------------------------------------------------------------------------ * OpenTok Initialization * -----------------------------------------------------------------------------------------------*/ $opentok = new OpenTok($config->opentok('key'), $config->opentok('secret')); /* ------------------------------------------------------------------------------------------------ * Setup MySQL * -----------------------------------------------------------------------------------------------*/ // mysql - replace user/pw and database name // Set env vars in /Applications/MAMP/Library/bin/envvars if you are using MAMP // MYSQL env: export CLEARDB_DATABASE_URL="mysql://root:root@localhost/adserverkit // MYSQL formate: username:pw@url/database $mysql_url = parse_url(getenv("CLEARDB_DATABASE_URL") ?: $config->mysql('mysql_url')); $dbname = substr($mysql_url['path'], 1); $host = $mysql_url['host']; if ($mysql_url['port']) { $host = $host . ':' . $mysql_url['port']; } $con = mysqli_connect($host, $mysql_url['user'], $mysql_url['pass']); // Check connection