Skip to content
Rewrite of CSH WebDrink. Includes updated interface and new API.
Branch: master
Clone or download
Pull request Compare This branch is 31 commits behind ComputerScienceHouse:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

WebDrink 2.0

A rewrite of the web interface for Drink, the networked vending machines on Computer Science House. It can be used for managing inventory, applying credits, dropping drinks, and more. It includes an updated, mobile-friendly interface and an API for easily creating new Drink clients.

Based on the original WebDrink. Uses Drink-JS to communicate with the Drink hardware.

WebDrink 2.0 is now LIVE (for all CSHers)! Check it out at!

Check out the API Documentation and develop your own Drink clients!

Found an issue? Want to request a feature? Send me an email or open a GitHub issue.

Why Update WebDrink?

  • Address usability concerns (make it mobile friendly, improve the admin experience, etc)
  • Expose an API to improve current/future development (mobile apps, new new WebDrink, etc)
  • Learning, I guess (Angular, RESTful API, etc)

It Uses:



Webdrink should be deployed with a configuration file, config.php, at the project root. It should have the following entries:

*	General configuration

define("API_BASE_URL", "api/index.php?request="); The base URL of the Drink API
define("DRINK_SERVER_URL", "") // Base URL for the Drink (websocket) server
define("LOCAL_DRINK_SERVER_URL", "http://localhost:3000"); // URL (and port) of test drink server (see /test directory)

*	Rate limit delays (one call per X seconds)

define("RATE_LIMIT_DROPS_DROP", 3); // Rate limit for /drops/drop

*	Development configuration
define("DEBUG", true); // true for test mode, false for production

define("DEBUG_USER_UID", "bencentra"); // If DEBUG is `true`, the UID of the test user (probably your own)
define("DEBUG_USER_CN", "Ben Centra"); // If DEBUG is `true`, the display name of the user (probably your own)

define("USE_LOCAL_DRINK_SERVER", true) // If set to `true` and DEBUG is `true`, will use a mock Drink server for developing

Database and LDAP Permission files

WebDrink expects two files - and - to be present and contain database and LDAP configuration information (respectively). Currently, they must be placed two directories above the WebDrink root. This is only mildly inconvenient for:

  • CSH systems: put these files in your home dir and WebDrink in your .html_pages
  • MAMP users: these files in the MAMP root and WebDrink in htdocs

Database contains database connection info and creates a global $pdo variable, used by WebDrink's database utility funtions (see utils/db_utils.php). You can create your own database from the schema file (drink_v2_schema.sql), or connect to the actual Drink database (ask an RTP for credentials).


// Database connection info
$dbName = "";
$dbHost = "";
$dbUser = ""; 
$dbPass = "";

// Create a PDO object and connect to the database
try {
	$pdo = new PDO(
      PDO::MYSQL_ATTR_FOUND_ROWS => true, 
catch (PDOException $e) {
    die('Database Connection Failed: ' . $e->getMessage());


LDAP contains LDAP connection info and creates a global $conn variable, used by WebDrink's LDAP utility functions (see utils/ldap_utils.php). For more information about CSH's LDAP setup, see this wiki article:


// LDAP connection info
$ldapUser = "";
$ldapPass = "";
$ldapHost = "";
$appDn = "ou=Apps,dc=csh,dc=rit,dc=edu";
$userDn = "ou=Users,dc=csh,dc=rit,dc=edu";

// Append the appropriate dn to the username
$ldapUser .= "," . $appDn;

// Connect to LDAP and bind the connection
try {
	$conn = ldap_connect($ldapHost);
	if (!ldap_bind($conn, $ldapUser, $ldapPass)) {
		die ('LDAP Bind Error...');
catch (Exception $e) {
	die ('LDAP Connection Failed: ' . $e->getMessage());



When developing, set DEBUG to true in config.php to fake Webauth authentication. All requests will be made as the test user (as defined in config.php). Don't be a jerk; put in your own username.

Dev Environment

In order to run WebDrink locally you'll need a web server, PHP (>=5.4), and MySQL.

  • OS X: MAMP
  • Windows: WAMP
  • Linux: Varies by distro (for example, Ubuntu)


There is currently no development LDAP setup, so you'll have to use CSH's server. This means any operations (i.e. credit additions/deductions) are for real.

Some operations require admin privileges. Contact an RTP to be given "drink admin" status to access these operations.

To set up a local database, you can import the schema from drink_v2_schema.sql.

Test Drink Server

In the /test directory is a mock Drink server. It will blindly respond (with success) all requests and doesn't care about SSL, allowing you to test Drink server behavior outside of CSH-net (or if the Drink server is down).

Make sure you have Node and NPM installed:

cd test
# Install dependencies
npm install
# Run the server
node index.js


For now, releases are a manual process (FTP-ing files to CSH servers).

When "releasing," make sure to set DEBUG to false in config.php!

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.