Skip to content

Commit

Permalink
Initial import.
Browse files Browse the repository at this point in the history
  • Loading branch information
theocharis.athanasakis committed Sep 27, 2008
0 parents commit 43e240a
Show file tree
Hide file tree
Showing 113 changed files with 11,877 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 404.shtml
@@ -0,0 +1,4 @@
<html>
<head><title>Error 404</title></head>
<p>The page you are trying to reach does not exist</p>
</html>
156 changes: 156 additions & 0 deletions DBsetup.php
@@ -0,0 +1,156 @@
<?
/*
Grinnell Plans. A web-based version of social .plans.
Copyright (C) 2002 by Jonathan Kensler
---
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---
If you need to contact me you may so at:
kenslerj@grinnell.edu
or
Jonathan Kensler
Box 07-04 Grinnell College
Grinnell, IA 50112
*/

//Issues the queries to set up the database



require("dbfunctions.php");
$mydbh = db_connect();

/*
mysql_query("CREATE TABLE accounts(
userid SMALLINT UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
username VARCHAR(16) NOT NULL,
UNIQUE INDEX (username),
created TIMESTAMP,
password VARCHAR(20),
email VARCHAR(64),
pseudo VARCHAR(64),
login DATETIME,
changed DATETIME,
plan TEXT,
poll TINYINT UNSIGNED,
group_bit CHAR(1),
spec_message VARCHAR(255),
grad_year CHAR(4)
)");
mysql_query("CREATE TABLE autofinger(
owner SMALLINT UNSIGNED NOT NULL,
INDEX (owner),
interest SMALLINT UNSIGNED NOT NULL,
INDEX (interest),
priority TINYINT UNSIGNED,
updated CHAR(1),
updtime DATETIME,
readtime DATETIME
)");
mysql_query("CREATE TABLE display(
userid SMALLINT UNSIGNED PRIMARY KEY,
text_color CHAR(6),
link_color CHAR(6),
visited_color CHAR(6),
bg_color CHAR(6),
panel_color CHAR(6),
header_style VARCHAR(16),
background VARCHAR(16),
panelside CHAR(1)
)");
mysql_query("CREATE TABLE opt_links(
userid SMALLINT UNSIGNED,
INDEX (userid),
linknum TINYINT UNSIGNED
)");
mysql_query("CREATE TABLE avail_links(
linknum TINYINT UNSIGNED PRIMARY KEY,
linkname VARCHAR(128),
descr TEXT,
html_code TINYTEXT
)");
mysql_query("CREATE TABLE system(
motd TEXT,
poll TEXT
)");
mysql_query("CREATE TABLE poll(
pollid TINYINT UNSIGNED PRIMARY KEY,
polltext TINYTEXT,
polltotal SMALLINT
)");
mysql_query("CREATE TABLE mainboard(
threadid SMALLINT UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
title VARCHAR(128),
created DATETIME,
lastupdated DATETIME,
userid SMALLINT UNSIGNED NOT NULL
)");
mysql_query("CREATE TABLE subboard(
messageid SMALLINT UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
threadid SMALLINT UNSIGNED NOT NULL,
INDEX (threadid),
created DATETIME,
userid SMALLINT UNSIGNED NOT NULL,
INDEX (userid),
title VARCHAR(128),
contents TEXT NOT NULL
)");
*/


mysql_query("CREATE TABLE stylesheet(
userid SMALLINT UNSIGNED PRIMARY KEY NOT NULL,
stylesheet tinytext
)");



//annihilate($mydbh, "accounts");
//annihilate($mydbh, "autofinger");
//annihilate($mydbh, "display");
//annihilate($mydbh, "opt_links");
//annihilate($mydbh, "avail_links");
//annihilate($mydbh, "system");
//annihilate($mydbh, "poll");
//annihilate($mydbh, "mainboard");
//annihilate($mydbh, "subboard");
//annihilate($mydbh, "stylesheet");

db_disconnect($mydbh);


?>
25 changes: 25 additions & 0 deletions LICENSE
@@ -0,0 +1,25 @@
/*
Grinnell Plans. A web-based version of social .plans.
Copyright (C) 2002 by Grinnellplans grinnellplans@gmail.com

---

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

---
If you need to contact us you may so at:
grinnellplans@gmail.com

*/
98 changes: 98 additions & 0 deletions anonymous.php
@@ -0,0 +1,98 @@
<?

session_start();
require("functions-main.php");//load main functions

$dbh = db_connect();//connect to database

$idcookie = $_SESSION['userid'];
$auth = $_SESSION['is_logged_in'];

$myprivl=setpriv($myprivl, $HTTP_COOKIE_VARS["thepriv"]);


if ($auth)//begin valid user display
{
mysql_query("delete from viewed_secrets where userid = $idcookie");
mysql_query("insert into viewed_secrets (userid, date) values($idcookie, now())");
mdisp_begin($dbh,$idcookie,$HTTP_HOST . $REQUEST_URI,$myprivl);}
else //begin guest user display
{gdisp_begin($dbh);}

?>


<p>

Here you can post anonymously. This page was created to help give wgemigh his plan back, and to make it possible to paginate an increasing number of secrets. Please add this page as an optional link under 'preferences'.
</p><p>
Secrets cannot be tracked by any Plans administrator. If you're still worried, you may log out before posting. We can exercise editorial discretion as to what shows up.

<a href="#" onClick =" document.getElementById('secrets').style.display = 'block';">Post a Secret </a></p>
<div id="secrets">
<form method="POST">

<textarea name="secret" rows=10 cols=50>
</textarea>
<input type="hidden" name="secret_submitted" value="1">
<input type="submit" value="Post">
</form>
</div>
<script>
<!--
document.getElementById('secrets').style.display = 'none';
-->
</script>
<?php

if ($_POST['secret_submitted']) {
$secret = $_POST['secret'];
$secret = cleanText($secret);
$sql = "insert into secrets(secret_text, date, display) values (substring('$secret',1,4000), now(), 'no')";
mysql_query($sql);
}

if ($auth) {

$count = 300;
$offset = $_GET['offset'];
if (! is_numeric($offset)) {
$offset = 0;
}

echo "<!--- $offset --->";


if ($_SERVER['REMOTE_ADDR'] == '70.12.157.227' || $_GET['show_all']) {
$select_query = "select * from secrets order by date desc limit $offset, $count";
} else {
$select_query = "select * from secrets where display = 'yes' or display = 'pref' order by date desc limit $offset, $count";
}

if (!$secrets =
mysql_query($select_query))
{ echo "No secrets";}
else {
while ($row = mysql_fetch_array($secrets)) {
echo '<p class="sub">';
$secret = $row['secret_text'];
$date = $row['date'];
$secretidno = $row['secret_id'];
echo "$secretidno <b>$date</b><br />\n";
echo "$secret\n";
}
echo '</p>';
}

}


if ($auth)//begin valid user display
{
mdisp_end($dbh,$idcookie,$HTTP_HOST . $REQUEST_URI,$myprivl);
} else
{gdisp_end();}

db_disconnect($dbh);

?>
68 changes: 68 additions & 0 deletions api/update-plan.rb
@@ -0,0 +1,68 @@
#!/usr/bin/ruby
# GrinnellPlans posting script v0.2
# Updated: 6/25/2006
# Author: Will Emigh (will@studiocypher.com)
# This program is provided as-is under an MIT license, although I would like to hear from you if you do
# something fun with it.
# Updated by [wellons]:
# use username instead of userid
# to work with PHP Sessions
# read update in from a file
# there's some bug in plans that makes us do more work for unix line-endings
# set user-agent


require 'net/http'
require 'cgi'

if ARGV[0].nil? || ARGV[1].nil? || ARGV[2].nil?
print "Usage: file-based-post username password file-containing-update\n"
print "This script prepends your plan with the date and the "
print "contents of the given file.\n"
exit
end

update_file = ARGV[2]
update_file_handle = File.new(update_file, "r")
update = update_file_handle.read()

username = ARGV[0]
password = CGI::escape(ARGV[1])
cookie = ''

Net::HTTP.start('www.grinnellplans.com') do |http|
path = '/index.php'
data = "username=#{username}&password=#{password}"
headers = {
'User-Agent' => "#{$0} #{$*}: version 0.2",
'Content-Type' => 'application/x-www-form-urlencoded'
}
resp, data = http.post(path, data, headers)
cookie = resp['Set-Cookie']


req = Net::HTTP::Get.new("/edit.php")
req['Cookie'] = cookie
response = http.request(req)
b = response.body.gsub(/[\n\r]/,'<br />')
entry = b.scan(/<textarea rows=\"14\" cols=\"70\" <br \/>name=\"plan\" wrap=\"virtual\" onkeyup=\"javascript:countlen\(\);\">(.*)<\/textarea>/)
@old_plan = entry[0][0]
@old_plan.gsub!(/<br \/>/,"\n\r")

# Fix unix linebreaks which get removed the second time you view the plan in edit.php
update.gsub!(/\n([^\r])/,"\n\r\\1")
new_plan = "[date]\n\r"+update+"\n\r\n\r"+CGI::unescapeHTML(@old_plan)
new_plan = CGI::escape(new_plan)

path = '/edit.php'
data = "plan=#{new_plan}&part=1"
headers = {
'Content-Type' => 'application/x-www-form-urlencoded'
}
headers['Cookie'] = cookie

# Make the post request
resp, data = http.post(path, data, headers)
end

print "Update posted.\n"

0 comments on commit 43e240a

Please sign in to comment.