General tidy up

This commit is contained in:
Kai Hendry
2014-07-11 14:44:35 +08:00
parent b29c51dee6
commit 00d95cdc9e
4 changed files with 8 additions and 93 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
u/*
active-users.txt
version.txt
secret.php

View File

@@ -1,7 +1,7 @@
MIT/X Consortium License
© 2011-2012 Kai Hendry <hendry@iki.fi>
Contributors to https://github.com/kaihendry/Greptweet
© 2011-2014 Kai Hendry <hendry@iki.fi>
Contributors https://github.com/kaihendry/greptweet/graphs/contributors
Jamie Kitson <jamie@kitten-x.com>
Pádraig Brady <http://www.pixelbeat.org>

View File

@@ -1,90 +0,0 @@
#!/bin/bash -e
# vim: set ts=4 sw=4
# apache_setenv('no-gzip', '1');
# TODO re-implement in PHP
exec 2>&1
cat <<END
Cache-Control: no-cache
Content-Type: text/html
END
badinput() {
echo "<h1>Bad input, parameter id $@</h1>"
exit
}
oldpwd=$PWD
saveIFS=$IFS
IFS='=&'
parm=($QUERY_STRING)
IFS=$saveIFS
if test ${parm[0]} == "id"
then
id=$(echo ${parm[1]} | tr -dc '[:alnum:]_' | tr '[:upper:]' '[:lower:]')
test ${#id} -gt 0 || badinput is empty
test ${#id} -lt 20 || badinput is too large
else
exit
fi
if test "${parm[2]}" == "o" # unused
then
test "${parm[3]}" && old=1
fi
cat <<END
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Fetching tweets of $id</title>
<link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="content">
END
if test -d u/$id
then
echo "<h1 class='alert alert-info'>Attempting to update $id</h1>"
else
# TODO: This API is deprecated!
if curl -sI http://api.twitter.com/1/users/lookup.xml?screen_name=${id} |
grep -q "Status: 404 Not Found"
then
echo "<h1 class='alert alert-info'>$id does not exist on twitter.com :(</h1>"
exit
fi
mkdir -p u/$id
fi
cd u/$id
ln -sf ../../index.html || true
ln -sf ../../grep.php || true
if echo $id | grep -q -v '_' # Underscores in domain names is a no no
then
cat <<END
<a href="http://$id.greptweet.com"><h1 class="alert alert-success">Goto http://$id.greptweet.com to grep!</h1></a>
END
else
cat <<END
<a href="http://$HTTP_HOST/u/$id"><h1 class="alert alert-success">Goto http://$HTTP_HOST/u/$id to grep!</h1></a>
END
fi
ln -sf $id.txt tweets.txt
test -h greptweet.appcache && rm -f greptweet.appcache
sed -e "s,TIMESTAMP,$(date)," ../../greptweet.appcache > greptweet.appcache
echo "<pre>"
../../fetch-tweets.sh $id & disown

View File

@@ -1,3 +1,4 @@
user-agent: *
disallow: /create.cgi
disallow: /create.php
disallow: /u/*
disallow: /f/*