Example #1
0
 public function createLoop($readStreamCompatible = false)
 {
     if ('Linux' === PHP_OS && !extension_loaded('posix')) {
         $this->markTestSkipped('libevent tests skipped on linux due to linux epoll issues.');
     }
     if (!extension_loaded('event')) {
         $this->markTestSkipped('ext-event tests skipped because ext-event is not installed.');
     }
     $cfg = null;
     if ($readStreamCompatible) {
         $cfg = new \EventConfig();
         $cfg->requireFeatures(\EventConfig::FEATURE_FDS);
     }
     return new ExtEventLoop($cfg);
 }
 public function __construct()
 {
     $ec = EventConfig::getInstance();
     $dbConnectionParams = $ec->getDBConnectionParams();
     $dbUser = $ec->getDBUser();
     $dbPass = $ec->getDBPass();
     parent::__construct($dbConnectionParams, $dbUser, $dbPass);
 }
 private function OLD_sendEMail($subject, $body)
 {
     $ec = EventConfig::getInstance();
     $ec->augmentIncludePath();
     include_once 'Mail.php';
     $recipients = $ec->getSMTPRecipient();
     $headers['From'] = $ec->getSMTPSender();
     $headers['To'] = $ec->getSMTPRecipient();
     $headers['Subject'] = $subject;
     $headers['Content-Type'] = 'text/plain; charset=UTF-8';
     $smtpinfo = $ec->getSMTPInfo();
     // Create the mail object using the Mail::factory method
     if (class_exists('Mail')) {
         $m = new Mail();
         $mail_object =& $m->factory('smtp', $smtpinfo);
         return true === $mail_object->send($recipients, $headers, $body);
     } else {
         return false;
     }
 }
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use ExChat\Server as ChatServer;
use ExHttp\Server as ConnectionHandler;
use SlideBuilder\Server as SlideServer;
use SlideBuilder\Builder as SlideBuilder;
use ExHttp\Router;
use ExHttp\StaticFile;
use EventConfig as EventBaseConfig;
/* 
	Using Select Loop due to LibEvent epolling which doesn't work with file reads 
	@see http://stackoverflow.com/questions/5456967/problem-handling-file-i-o-with-libevent2
	@todo look at possibly using libev
*/
//$loop 			= new React\EventLoop\StreamSelectLoop();
$cfg = new \EventConfig();
$cfg->requireFeatures(EventBaseConfig::FEATURE_FDS);
$loop = new React\EventLoop\ExtEventLoop($cfg);
$documentRoot = getcwd();
$slidesDir = $documentRoot . DIRECTORY_SEPARATOR . 'slides';
echo "Watching directory: " . $documentRoot . PHP_EOL;
/* 
	slide server and builder 
*/
$slideBuilder = new SlideBuilder($loop, $slidesDir);
$slideServer = new SlideServer($slideBuilder);
/* 
	Directory monitor 
*/
$inotify = new MKraemer\ReactInotify\Inotify($loop);
$inotify->add($documentRoot . '/slides/', IN_CREATE | IN_DELETE | IN_MODIFY);
 * To run, you will need to make sure you have sudo access as it is currently
 * configured to run the web server on port 80 and have port 8080 accessible
 * as that is where the websocket server is configured to listen.
 *
 * when done, point your browser to port 80 of your machine and you should see
 * a little avatar pop up - add more browsers to see more avatars.
 *
 * To chat simply enter a message and hit enter or press the send button.
 */
require_once '/var/www/reactphp/vendor/autoload.php';
use ExHttp\Server as ConnectionHandler;
use ExHttp\StaticFile;
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
$cfg = new \EventConfig();
$cfg->requireFeatures(\EventConfig::FEATURE_FDS);
$loop = new React\EventLoop\ExtEventLoop($cfg);
$documentRoot = getcwd();
// Set up our WebSocket server for clients wanting real-time updates
$webSock = new React\Socket\Server($loop);
$webSock->listen(8080, '0.0.0.0');
// Binding to 0.0.0.0 means remotes can connect
$webServer = new Ratchet\Server\IoServer(new Ratchet\Http\HttpServer(new Ratchet\WebSocket\WsServer(new Ratchet\Wamp\WampServer(new ExGame\Server()))), $webSock);
$router = new ExHttp\Router();
$fileHandler = new StaticFile($documentRoot, $loop);
$router->setFileHandler($fileHandler);
$httpSocket = new React\Socket\Server($loop);
$httpSocket->listen(81, '0.0.0.0');
$httpServer = new IoServer(new HttpServer(new ConnectionHandler($router)), $httpSocket, $loop);
$loop->run();
 public function dispatchRequest()
 {
     require_once 'EventConfig.php';
     if (!isset($_REQUEST['torch'])) {
         ob_end_clean();
         header('HTTP/1.0 404 Not Found');
         exit;
     }
     try {
         $pdo = new EventPDO();
     } catch (PDOException $e) {
         echo 'Bummer! Our database is currently unavailable. Please try again later.';
         return;
     }
     $ep = EventConfig::getInstance();
     if (isset($_POST['pass']) && isset($_POST['user']) && hash('whirlpool', $ep->getAccessSalt() . $_POST['pass']) === $ep->getAccessPass() && $_POST['user'] === $ep->getAccessUser()) {
         $this->showData($pdo);
         return;
     }
     $this->displayForm($pdo);
 }
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * http://www.gnu.org/copyleft/gpl.html
 *
 */
if (isset($_POST['email']) && strlen($_POST['email']) < 150) {
    require_once 'EventConfig.php';
    $ec = EventConfig::getInstance();
    $ec->augmentIncludePath();
    $body = 'supposed sender: ' . $_POST['name'] . ' <' . $_POST['email'] . ">\n" . $_POST['message'];
    $sender = filter_var($ec->getSMTPSender(), FILTER_VALIDATE_EMAIL);
    mail($ec->getSMTPRecipient(), $_POST['subject'], $body, $sender ? 'From: ' . $sender : '');
    $destination = explode('/', $_SERVER['REQUEST_URI']);
    array_pop($destination);
    $destination = implode('/', $destination);
    if (!$destination) {
        $destination = '/';
    }
    setcookie('halleilujah-mail-success', '1', time() + 5, '/');
    header('Location: ' . $destination, true, 303);
    echo 'Thanks for your message.';
} else {
    setcookie('halleilujah-mail-success', '0', time() + 5, '/');