Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Caceres rchrd2

View GitHub Profile
@rchrd2
rchrd2 / stdin2www
Last active Jan 7, 2017 — forked from cwarden/stdin2www.sh
Show stdin in a web browser (for Mac OS X)
View stdin2www
#!/bin/sh
# read from stdin, write to a temp file, open the temp file in a browser, then delete it
tmpfile=$(mktemp).html; cat > $tmpfile; open $tmpfile; #rm $tmpfile
View test-php-basic-auth.php
<?php
function require_auth() {
$AUTH_USER = 'admin';
$AUTH_PASS = 'admin';
header('Cache-Control: no-cache, must-revalidate, max-age=0');
$has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));
$is_not_authenticated = (
!$has_supplied_credentials ||
$_SERVER['PHP_AUTH_USER'] != $AUTH_USER ||
$_SERVER['PHP_AUTH_PW'] != $AUTH_PASS