function _exit() { _log(L_INFO, "Shutting down..."); $bounce = Bounce::getInstance(); $bounce->end(); }
$GLOBALS['configfile'] = $value; break; case 'l': _log(L_INFO, 'Using log file %s.', $value); $GLOBALS['logfile'] = $value; break; case 'f': $GLOBALS['fork'] = true; break; } } } if ($GLOBALS['fork'] === true) { _log(L_DEBUG, 'Forking into the background...'); $pid = pcntl_fork(); if ($pid == -1) _log(L_FATAL, 'Failed to fork into the background. Exiting.'); else if ($pid) { _log(L_DEBUG, 'Forked successfully. Exiting parent.'); exit; } else $GLOBALS['forked'] = true; } $bounce = Bounce::getInstance(); $bounce->start();
static function decodeClicker($encoded, &$id) { $mixed = Bounce::decode($encoded); if (!is_numeric($mixed)) { return FALSE; } $mixed = str_split($mixed); $nid = ""; for ($i = 0; $i < count($mixed); $i = $i + 2) { $nid .= $mixed[$i]; } $id = $nid; return TRUE; }
<?php /* * Description: Script utilizes Bounce class to track and redirect URLs * Notes: Import schema into database first and set DSN respectively * Apache .htaccess config * RewriteCond %{QUERY_STRING} ^([A-Za-z0-9]+)$ * RewriteRule ^$ /bounce_app.php?%1 [L] * Author: Jeffrey Clark */ define('BOUNCE_DSN', 'sqlite:' . dirname(__FILE__) . '/bounce.sqlite3'); require_once 'bounce.php'; # Bounce::debug_request_log(); if (!file_exists(BOUNCE_DSN)) { echo file_get_contents('./bounce-error.html'); exit; } Bounce::setPDO(new PDO(BOUNCE_DSN)); $bounce = Bounce::To($_SERVER['QUERY_STRING']); if (!$bounce) { echo file_get_contents('./bounce-error.html'); } elseif (!$bounce->findItem()) { echo file_get_contents('./bounce-invalid.html'); } else { if (!$bounce->findClicker()) { $bounce->createClicker(); } if (!$bounce->go()) { echo file_get_contents('./bounce-disabled.html'); } }