| @@ -0,0 +1,168 @@ | ||
| <?PHP | ||
|
|
||
| include("include/library.php"); | ||
| dbconnect(); | ||
| $user = login("Any"); | ||
| include("include/userfuncs.php"); | ||
|
|
||
| $user = mysql_fetch_array(safequery("select * from person where name = '".$_SERVER['PHP_AUTH_USER']."'")); | ||
|
|
||
| $PHP_SELF = $_SERVER['PHP_SELF']; | ||
|
|
||
| build_header("Editing {$user['name']}'s details"); | ||
|
|
||
| function newrow(){ | ||
| echo "<br>\n"; | ||
| } | ||
|
|
||
| function showform($defaults){ | ||
|
|
||
| html_form_start("newuser", $_SERVER['PHP_SELF']); | ||
|
|
||
| // html_textbox($name, $label, $maxlength, $default) | ||
|
|
||
| html_hidden("id", $defaults[0]); | ||
|
|
||
| html_textbox("name", "Name:", 255, $defaults[1]); | ||
| newrow(); | ||
| html_textbox("email", "Email Address:", 255, $defaults[2]); | ||
| newrow(); | ||
| html_textbox("homepage", "Home Page:", 255, $defaults[3]); | ||
| newrow(); | ||
| html_password("password", "Enter desired password:"); | ||
| newrow(); | ||
| html_password("confirm_pw", "Re-enter Password to confirm"); | ||
| newrow(); | ||
|
|
||
| // chkbox($name, $label, $checked) | ||
| echo "e-mail me when..."; | ||
| newrow(); | ||
| html_chkbox("mor", "...I have new relationships", $defaults[4]); | ||
| newrow(); | ||
| html_chkbox("moc", "...people join my clique", $defaults[5]); | ||
| newrow(); | ||
| html_chkbox("mom", "...people send me messages", $defaults[6]); | ||
| newrow(); | ||
| html_chkbox("moca", "...I'm accepted into cliques", $defaults[7]); | ||
| newrow(); | ||
| html_chkbox("mou", "...AFPhrid is upgraded", $defaults[8]); | ||
| newrow(); | ||
| $buttons = array( | ||
| #array (Label, Name, Button type) | ||
| array ('Modify User', 'submit', 'submit'), | ||
| array ('Reset Form', 'reset', 'reset') | ||
| ); | ||
|
|
||
| html_buttons($buttons); | ||
|
|
||
| html_form_close(); | ||
| } | ||
|
|
||
| if (isset($_REQUEST['submit'])){ | ||
|
|
||
| $validate = ""; | ||
|
|
||
| echo "<ul>"; | ||
|
|
||
| if ($_REQUEST['name'] != $user['name']){ | ||
| $validate .= validate_name($_REQUEST['name']); | ||
| } else { | ||
| echo "<li>Skipping Username Validation (Unchanged)"; | ||
| } | ||
|
|
||
| if ($_REQUEST['email'] != $user['email']){ | ||
| $validate .= validate_email($_REQUEST['email']); | ||
| } else { | ||
| echo "<li>Skipping Email Validation (Unchanged)"; | ||
| } | ||
|
|
||
| $validate .= validate_homepage($_REQUEST['homepage']); | ||
| $validate .= validate_password($_REQUEST['password'], $_REQUEST['confirm_pw'], "modify"); | ||
|
|
||
| echo $validate; | ||
|
|
||
| echo "</ul>"; | ||
| $valid_submits = array("id", "name", "password", "email", "homepage", | ||
| "mor", "moc", "mom", "moca", "mou"); | ||
|
|
||
| foreach($valid_submits as $submit){ | ||
| if (isset($_POST["$submit"])){ | ||
| $$submit = $_POST["$submit"]; | ||
| } else { | ||
| $$submit = false; | ||
| } | ||
| } | ||
|
|
||
| if ($validate == ""){ | ||
|
|
||
| html_heading("Yay, Passed",2,""); | ||
|
|
||
|
|
||
| echo "<p>Okay, Updating Info......</p>"; | ||
|
|
||
| $av_prefs = array('mor', 'moc', 'mom', 'moca', 'mou'); | ||
| $myprefs = "-"; | ||
|
|
||
| foreach ($av_prefs as $thispref){ | ||
| if ($$thispref){ | ||
| $myprefs .= $thispref ."-"; | ||
| } | ||
| } | ||
| $name = addslashes($name); | ||
| $email = addslashes($email); | ||
| if ($homepage == "http://"){$homepage = "";} | ||
| $homepage = addslashes($homepage); | ||
| $password = addslashes($password); | ||
|
|
||
|
|
||
| $query = "update person set "; | ||
| $query .= "name = '$name', "; | ||
| $query .= "email = '$email', "; | ||
| $query .= "homepage = '$homepage', "; | ||
| if($password != ""){$query .= "password = password('$password'), ";} | ||
| $query .= "prefs = '$myprefs' "; | ||
|
|
||
| $query .= "where id = '$id'"; | ||
|
|
||
| safequery($query); | ||
| logthis($name, "modify", $name . " changed their information", $query); | ||
|
|
||
| echo "<p>Congrats, it seems to have worked....</p>"; | ||
|
|
||
|
|
||
| } else { | ||
| html_heading("Failed. Bad.",2,""); | ||
|
|
||
| $defaults = array($id, $name, $email, $homepage, $mor, $moc, $mom, $moca, $mou); | ||
| showform($defaults); | ||
| } | ||
|
|
||
|
|
||
| }else{ | ||
|
|
||
| html_heading("Oh, Hi ".$user['name'],1,""); | ||
|
|
||
| $form = array( | ||
| $user['id'], | ||
| $user['name'], | ||
| $user['email'], | ||
| $user['homepage'] | ||
| ); | ||
|
|
||
|
|
||
| $prefs = array("mor", "moc", "mom", "moca", "mou"); | ||
|
|
||
| foreach ($prefs as $thispref){ | ||
| if (strstr($user['prefs'], "-".$thispref."-")){ | ||
| $form[] = true; | ||
| } else { | ||
| $form[] = false; | ||
| } | ||
| } | ||
| showform($form); | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| build_footer("Edit User"); | ||
| ?> |
| @@ -0,0 +1,80 @@ | ||
| <?PHP | ||
| /* | ||
| Afphrid 1.5 | ||
| File: faq.php | ||
| Purpose: FAQ | ||
| Dates: C: 5/3/02 M: 2002-06-09 | ||
| Author: Nicholas 'Aquarion' Avenell | ||
| Changes: | ||
| */ | ||
| include("include/library.php"); // Useful Functions | ||
|
|
||
| build_header("Help - FAQ"); | ||
|
|
||
| dbconnect(); | ||
|
|
||
| include("include/help.html") | ||
| ?> | ||
| <h1>Questions I've Never Been Asked:</h1> | ||
| <ul> | ||
| <li>AFP | ||
| <li>AFP Relations | ||
| <li>Why? | ||
| <li>Afphrid | ||
| <li>Afphrid2 | ||
| <li>Afphrid3 | ||
| </ul> | ||
|
|
||
| <h2>AFP</h2> | ||
| <p>Alt.fan.pratchett is a newsgroup based around the life and works of Terry Pratchett. It's also quite a bit more than that, in that it's a community of likeminded - and occasionally non-likeminded - people who talk to each other, be it by online chat, the newsgroup itself, or Real Life. It has a number of conventions, including cats and chocolate, and you can find out much more at <a href="http://www.lspace.org/fandom/afp/">the lspace AFP page</a>.</p> | ||
|
|
||
| <h2>AFP Relations</h2> | ||
| <p>One of these conventions is that of Relationships. Once upon a time, someone saw a post that made them go "Oooooooh, nice", and followed up with "Will you marry me?". This developed into the current state of play, where we have afphiancee's, afpsisters, wives, husbands (often these two are related, but not always) librarians and mice. Clearly, there needed to be a central repository where all this goes, that people can look at it.</p> | ||
|
|
||
| <p>Someone should do something.</p> | ||
|
|
||
| <h2>Why?</h2> | ||
| <p>Sitting in a database lecture sometime in 2001, I needed an example. I was being taught the therory behind databases, how they worked, and I needed an example to work though in my head to see if I understood it. And since they were relational database, I thought of relations, and of AFP. Then I drew out a form of relationships, normalised it, and did some specifications for how it would work.</p> | ||
|
|
||
| <p>Academic exercise, you understand. Like "How to kill the Hogfather"</p> | ||
|
|
||
| <p>Then, one week in September, I got bored, found my old notes, and coded it. Afphrid, the Alt.fan.pratchet heroic, relational (& impossible) database v1 was <a href="http://groups.google.com/groups?selm=aa22pd%2465tuv%241%40ID-138064.news.dfncis.de">born</a>.</p> | ||
|
|
||
| <h2>Afphrid</h2> | ||
| <p>In the beginning was AFPhrid, the Alt.Fan.Pratchett Heroic Impossible | ||
| Relational Database. And it was designed by a person fresh out of Uni, and by | ||
| golly did it show. And it ran for six months, and various hacks were put in | ||
| place to make it work properly, most of which involving escaping strings.</p> | ||
|
|
||
| <p>When the new version of PHP was released, fixing a number of security holes, | ||
| the old version of Afphrid didn't work with it, and rather than make a bodge-job | ||
| of repairing the complex system, its designer and coder, Aquarion, decided to | ||
| <a href="http://groups.google.com/groups?selm=gn9pbuodff9g7o5dl3jq3en1m1sv9qqfo5%404ax.com">rewrite it</a> under the traditional banners of Truth, Love, and Not Using User Input | ||
| For Primary Keys.</p> | ||
|
|
||
| <h2>Afphrid 2</h2> | ||
| <p>Almost two months later, it was still unfinished, and Aquarion made a decision, | ||
| this had to *be* working soon, otherwise it would be too hopelessly out of date. | ||
| So he took some of the more radical database changes (that he hadn't already | ||
| implemented) and placed them into a fictional "<a href="development.php">Back Burner</a>" state until the main | ||
| system was finished, Put most of the less basic features (like cliques) into a | ||
| "Stage Two" state, and got to work on getting the main system back up and running | ||
| . It still isn't - quite, but it's closer. The future is bright, the future is | ||
| an attractive green gradient.</p> | ||
|
|
||
| <p> | ||
| I've still got a lot to do, putting cliques back for starters. You can check on the progress, and see some info on what has *actually* changed at the <a href="development.php">Development Page</a>. | ||
| </p> | ||
|
|
||
| <h2>Afphrid 3</h2> | ||
| <blockquote cite="http://groups.google.com/groups?q=Afphrid&start=20&hl=en&lr=&ie=UTF8&oe=UTF8&selm=slrn9vkepc.o9u.usenet%40sacrifice.bedlam.bogus&rnum=23">"AFPrelationships are easy to document, providing you don't | ||
| even *attempt* to rationalise them"<br> - Afphrid notes, June 2001 | ||
| </cite> | ||
|
|
||
| <p>Afphrid will be rewritten in Perl, and the database sceme will be changed to be able to *understand* relationships. Soon.</p> | ||
| <?PHP | ||
| build_footer("FAQ"); | ||
| ?> |
| @@ -0,0 +1,112 @@ | ||
| <?PHP | ||
| ////////////////////////////////////////////////////////// | ||
| // Title: Mailpassword | ||
| // Project: | ||
| // Description: | ||
| // | ||
| // Authour: Nicholas Avenell | ||
| // Date: | ||
| // 04/10/01: | ||
| // + Changelog | ||
| // + error management system implimented | ||
|
|
||
| function generatepassword() { | ||
| /* | ||
| * Pronounceable password generator | ||
| * version 1.0beta | ||
| * Inspired by a question made by: georgcantor_at_geocities.com | ||
| * in the PHPBuilder discussion forum | ||
| * (c) Jesus M. Castagnetto, 1999 | ||
| * Modified by Aquarion | ||
| * GPL'd code, see www.fsf.org for more info | ||
| */ | ||
|
|
||
| $words = "words"; /* the file w/ the words */ | ||
| $cut_off = 5; /* minimum number of letters in each word */ | ||
| $min_pass = 2; /* minimum number of words in password */ | ||
| $max_pass = 2; /* maximum number of words in password */ | ||
|
|
||
| /* read the external file into an array */ | ||
| $fp = fopen($words, "r"); | ||
|
|
||
| if (!fp) { | ||
| fuckup($PHP_AUTH_USER, $PHP_SELF, "Word Generator", "Could not open word generator file", "Couldn't open $words"); | ||
| exit; | ||
| } else { | ||
| /* assuming words of up to 127 characters */ | ||
| while(!feof($fp)) { | ||
| $tword = trim(fgets($fp,128)); | ||
|
|
||
| /* check for minimum length and for exclusion of numbers */ | ||
| if ((strlen($tword) >= $cut_off) && !ereg( "[0-9]",$tword)) { | ||
| $word[] = strtolower($tword); | ||
| } | ||
| } | ||
| fclose($fp); | ||
| } | ||
|
|
||
| /* generate the password */ | ||
|
|
||
| $size_word = count($word); | ||
| srand((double)microtime()*1000000); | ||
| $n_words = rand($min_pass,$max_pass); | ||
|
|
||
| /* use the Mersenne Twister for a better random */ | ||
| #mt_srand((double)microtime()*1000000); | ||
| #$n_words = mt_rand($min_pass,$max_pass); | ||
|
|
||
| $seperators = array ("!","*","|","_","+","-","^","%","#","$","£") ; | ||
| $seperator = array_rand($seperators); | ||
|
|
||
|
|
||
| for ($i=0; $i < $n_words; $i++) { | ||
| $pass .= $word[rand(0,($size_word - 1))] . $seperators[$seperator]; | ||
| } | ||
|
|
||
| /* print the password */ | ||
| return substr($pass,0,-1); | ||
|
|
||
|
|
||
| } | ||
|
|
||
| include("include/library.php"); | ||
| dbconnect(); | ||
| #$user = login("Any"); | ||
|
|
||
| $PHP_SELF = $_SERVER['PHP_SELF']; | ||
|
|
||
| build_header("Reset Password"); | ||
|
|
||
| if (!isset($_POST['id'])){ | ||
| die("No ID Specified"); | ||
| }; | ||
|
|
||
| $r = safequery("select * from person where id = ".$_POST['id']); | ||
| if (mysql_num_rows($r) == 0){ | ||
| die("That ID Doesn't exist"); | ||
| }; | ||
| $user = mysql_fetch_array($r); | ||
|
|
||
| echo "<h1>Forgotten Password for ".$user['name']."</h1>"; | ||
|
|
||
| $newpassword = generatepassword(); | ||
| safequery("update person set password = password('$newpassword') where id = '{$user['id']}'"); | ||
|
|
||
| $message = "Hello {$user['name']}, This is Aquarion's Afphrid system, emailing\n" | ||
| ."you to tell of your New! Improved! password.\n" | ||
| ."Okay, Due to the way the system works, I can't actually find out what \n" | ||
| ."your password is, so I've set it to something new.\n" | ||
| ."The new password is:\n\n\t$newpassword\n\n I recomend " | ||
| ."you go to the site <http://www.afphrid.org.uk>\n and change " | ||
| ."it."; | ||
|
|
||
| sendmessage($user['id'], 0, "Recovered Password", $message, "email"); | ||
|
|
||
|
|
||
| echo "<h1>New Password sent to {$user['email']}</h1>"; | ||
| echo "<p>If this is unhelpful, talk to <a href=\"mailto:nicholas@aquarionics.com\">nicholas@aquarionics.com</a>"; | ||
|
|
||
|
|
||
|
|
||
| build_footer("Lost Password"); | ||
| ?> |
| @@ -0,0 +1,60 @@ | ||
| <?PHP | ||
| /* | ||
| Afphrid 1.5 | ||
| File: faq.php | ||
| Purpose: FAQ | ||
| Dates: C: 5/3/02 M: 2002-06-09 | ||
| Author: Nicholas 'Aquarion' Avenell | ||
| Changes: | ||
| */ | ||
| include("include/library.php"); // Useful Functions | ||
|
|
||
| build_header("Help - Quick Guide"); | ||
|
|
||
| dbconnect(); | ||
|
|
||
| include("include/help.html") | ||
| ?> | ||
| <h1>Quick Guide</h1> | ||
| How To Use AFPHRID, the | ||
| Alt Fan Pratchett Heroic Relational/Impossible Database. | ||
|
|
||
| <dl> | ||
|
|
||
| <dt>One: On the getting of accounts.</dt> | ||
|
|
||
| <dd>In order to use AFPRHID, you will need an account.<br> | ||
| Go to the afphrid page, and select "New User"<br> | ||
| Fill in the form of forminess, and Get Thyself An Account.<br> | ||
|
|
||
| <dt>Two: On The Logging In Of Accounts.</dt> | ||
|
|
||
| <dd>From the Front Page, click "User Page"<br> | ||
| When the nice box appears asking for your Username and | ||
| Password, Give it to the nice box.</dd> | ||
|
|
||
| <dt>Three: On The Creation Of Relationships</dt> | ||
|
|
||
| <dd>From the User Page, scroll to "New Relationship"<br> | ||
| Fill in this form with Information<br> | ||
| Click "Add Relationship"</dd> | ||
|
|
||
| <dt>Four: On The Admitting To Relationships</dt> | ||
|
|
||
| <dd>In order for a relationship to be active, both | ||
| sides must admit to it. The person you attempt to relate | ||
| to will - if he/she asked for it - get an email requiring | ||
| they confirm the relationship. To do this, you go to the | ||
| user page as described above, and in your Relationships | ||
| section you have the option of "Accept | Deny" beside a | ||
| person, and relationship, name. Click one.<br> | ||
|
|
||
| Congratulations, that's how to use it.</dd> | ||
| </dl> | ||
|
|
||
| <?PHP | ||
| build_footer("Front Page"); | ||
| ?> |
| @@ -0,0 +1,6 @@ | ||
| <div class="rightmenu"> | ||
| <h2>Help</h2> | ||
| <a href="faq.php">Frequently Asked Questions</a><br> | ||
| <a href="notes.php">System Notes</a><br> | ||
| <a href="notes.php">Quick Guide</a><br> | ||
| </div> |
| @@ -0,0 +1,77 @@ | ||
| <?PHP | ||
| /* | ||
| Afphrid 1.5 | ||
| File: library.php | ||
| Purpose: Useful functions for afphrid | ||
| Dates: C: 5/3/02 M: 5/3/02 | ||
| Author: Nicholas 'Aquarion' Avenell | ||
| Changes: | ||
| */ | ||
| function html_heading($text, $size, $class){ | ||
| if ($class != ""){$class = " class=\"$class\"";} | ||
| echo "<h".$size."$class>".$text."</h".$size.">"; | ||
| } | ||
|
|
||
| function html_hidden($name, $value){ | ||
| echo "<input type=\"hidden\" name=\"$name\" value=\"$value\">\n\n"; | ||
| } | ||
|
|
||
| function html_chkbox($name, $label, $checked){ | ||
| echo "<LABEL for=\"$name\">"; | ||
| echo " <INPUT type=\"checkbox\" id=\"$name\" name=\"$name\""; | ||
| if ($checked){ | ||
| echo " checked"; | ||
| } | ||
| echo "> $label"; | ||
| echo "</LABEL>\n\n"; | ||
| } | ||
|
|
||
| function html_lesshidden($name, $label, $default, $display){ | ||
| echo "<LABEL for=\"$name\">$label "; | ||
| echo " <INPUT type=\"hidden\" id=\"$name\" name=\"$name\" " | ||
| ."value=\"$default\"> ".$display; | ||
| echo "</LABEL>\n\n"; | ||
| } | ||
|
|
||
| function html_textbox($name, $label, $maxlength, $default){ | ||
| echo "<LABEL for=\"$name\">$label "; | ||
| echo " <INPUT type=\"text\" id=\"$name\" name=\"$name\" " | ||
| ."value=\"$default\" maxlength=\"$maxlength\">"; | ||
| echo "</LABEL>\n\n"; | ||
| } | ||
|
|
||
| function html_password($name, $label){ | ||
| echo "<LABEL for=\"$name\">$label "; | ||
| echo " <INPUT type=\"password\" id=\"$name\" name=\"$name\" " | ||
| ."maxlength=\"255\">"; | ||
| echo "</LABEL>\n\n"; | ||
| } | ||
|
|
||
| function html_textarea($name, $label, $rows, $cols, $default){ | ||
| echo "<LABEL for=\"$name\">$label "; | ||
| echo " <textarea name=\"$name\" rows=\"$rows\" cols=\"$cols\">\n"; | ||
| echo $default; | ||
| echo "</textarea>\n"; | ||
| echo "</LABEL>\n\n"; | ||
| } | ||
|
|
||
| function html_form_start($name, $action){ | ||
| echo "<FORM METHOD=POST ACTION=\"$action\">\n\n"; | ||
|
|
||
| } | ||
|
|
||
| function html_buttons($buttons){ | ||
| foreach ($buttons as $button){ | ||
| echo "<INPUT name=\"". $button[1] ."\" TYPE=\"" | ||
| . $button[2] ."\" value=\"". $button[0] ."\">"; | ||
| } | ||
| } | ||
|
|
||
| function html_form_close(){ | ||
| echo "</FORM>\n"; | ||
| } | ||
|
|
||
| ?> |
| @@ -0,0 +1,330 @@ | ||
| <?PHP | ||
| /* | ||
| Afphrid 1.5 | ||
| File: library.php | ||
| Purpose: Useful functions for afphrid | ||
| Dates: C: 5/3/02 M: 5/4/02 | ||
| Author: Nicholas 'Aquarion' Avenell | ||
| Changes: | ||
| */ | ||
| include("html.php"); // PHP functions to generate HTML. | ||
|
|
||
| function linkName($name){ | ||
| return "<a href=\"/viewme.php?id=".$name."\">".$name."</a>"; | ||
| } | ||
|
|
||
|
|
||
| function parseRSS($rss) | ||
| { | ||
|
|
||
| $path = isset($url_parts["path"]) ? $url_parts["path"] : "/"; | ||
|
|
||
| $tag = ""; | ||
| $isItem = false; | ||
| $isChannel = false; | ||
| $i = 0; | ||
| global $contents; | ||
|
|
||
| $saxparser = xml_parser_create(); | ||
| if (!$saxparser) die("Could not create XML Parser. You may not have the appropriate PHP extensions installed. See <a href=\"http://www.php.net/xml\">http://www.php.net/xml</a> for more information."); | ||
| xml_parser_set_option($saxparser, XML_OPTION_CASE_FOLDING, false); | ||
| xml_set_element_handler($saxparser, 'sax_start', 'sax_end'); | ||
| xml_set_character_data_handler($saxparser, 'sax_data'); | ||
|
|
||
| function sax_start($parser, $name, $attribs) | ||
| { | ||
| global $tag, $isItem, $isChannel, $i; | ||
|
|
||
| $tag = $name; | ||
|
|
||
| switch ($name) | ||
| { | ||
| case "channel": | ||
| $isChannel = true; | ||
| $isItem = false; | ||
| break; | ||
| case "item": | ||
| $i++; | ||
| $isChannel = false; | ||
| $isItem = true; | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| function sax_end($parser, $name) | ||
| { | ||
| } | ||
|
|
||
| function sax_data($parser, $data) | ||
| { | ||
| global $tag, $isItem, $isChannel, $contents, $i; | ||
| if ($data != "\n") | ||
| { | ||
| if ($isChannel && !$isItem && strlen(trim($data))) | ||
| (!isset($contents["channel"][$tag]) || !strlen($contents["channel"][$tag])) ? | ||
| $contents["channel"][$tag] = addslashes($data) : | ||
| $contents["channel"][$tag].= addslashes($data) ; | ||
| elseif ($isItem && strlen(trim($data))) | ||
| (!isset($contents[$i-1][$tag]) || !strlen($contents[$i-1][$tag])) ? | ||
| $contents[$i-1][$tag] = addslashes($data) : | ||
| $contents[$i-1][$tag].= addslashes($data) ; | ||
| } | ||
| } | ||
|
|
||
| $fp = @fopen($rss, "r"); | ||
| if ($fp) | ||
| { | ||
| while ($data = fread($fp, 4096)) | ||
| { | ||
| $parsedOkay = xml_parse($saxparser, $data, feof($fp)); | ||
|
|
||
| if (!$parsedOkay && xml_get_error_code($saxparser) != XML_ERROR_NONE) | ||
| { | ||
| $error ="XML Error in File: ".xml_error_string(xml_get_error_code($saxparser))." at line ".xml_get_current_line_number($saxparser); | ||
| $contents[0] = array( | ||
| 'title' => $error, | ||
| 'link' => "http://feeds.archive.org/validator/check?url=".urlencode($rss) | ||
| ); | ||
| } | ||
| } | ||
| } else { | ||
|
|
||
| } | ||
|
|
||
| xml_parser_free($saxparser); | ||
| fclose($fp); | ||
|
|
||
| return $contents; | ||
| } | ||
|
|
||
|
|
||
| function build_header($title){ | ||
| echo "<!doctype html public \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n" | ||
| ."<html>\n" | ||
| ."<head>\n" | ||
| ."<title> [AFPHRID2] $title</title>\n" | ||
| ."<meta name=\"Generator\" content=\"Afphrid 2\">\n" | ||
| ."<meta http-equiv=\"content-type\"" | ||
| ."content=\"text/html; charset=iso-8859-1\">\n" | ||
| ."<meta name=\"Author\" content=\"Nicholas 'Aquarion' Avenell\">\n" | ||
| ."<meta name=\"Keywords\" content=\"\">\n" | ||
| ."<meta name=\"Description\" content=\"\">\n" | ||
| ."<style type=\"text/css\">\n" | ||
| ."\t@import \"afphrid.css\";\n" | ||
| ."</style>\n" | ||
| ."</head>\n" | ||
|
|
||
| ."<body>\n" | ||
| ."<div id=\"header\">\n" | ||
| ."<img src=\"images/logo.gif\" width=\"298\" height=\"157\" border=0 alt=\"Afphrid2\">\n" | ||
| ."</div>\n" | ||
| ."<div class=\"menubar\">\n" | ||
| ."<table width=\"100%\" cellspacing=0 cellpadding=0 border=0>\n" | ||
| ."<tr>\n" | ||
| ."\t<td>". date("D j F Y, g:ia (T)") ."</td>\n" | ||
| ."\t<td align=\"right\">" | ||
| ." [ <a class=\"barlink\" href=\"user.php\">User Page</a>" | ||
| ." | <a class=\"barlink\" href=\"view.php\">View Stuff</a>" | ||
| ." | <a class=\"barlink\" href=\"index.php\">Front Page</a>" | ||
| ." | <a class=\"barlink\" href=\"http://www.aquarionics.com\">Aquarionics</a>" | ||
| ." ]</td>\n" | ||
| ."</tr>\n" | ||
| ."</table>\n" | ||
|
|
||
| ."</div>"; | ||
|
|
||
| } | ||
|
|
||
| function build_footer($page_id){ | ||
| $filemod = filemtime($_SERVER['SCRIPT_FILENAME']); | ||
| $filemodtime = date("D j F Y, g:ia (T)", $filemod); | ||
|
|
||
| echo "<div class=\"menubar\">"; | ||
| echo "Updated " . $filemodtime | ||
| #." by <A class=\"barlink\" HREF=\"mailto:afphrid@aquarionics.com\">" | ||
| #."afphrid@aquarionics.com</A> " | ||
| ." | <a class=\"barlink\" href=\"bugreport.php?page=$page_id\">Bug Report</a>" | ||
| ." | <a class=\"barlink\" href=\"help.php\">Help</a>" | ||
| ." | <a class=\"barlink\" href=\"powerpage/view_log.php\">Transaction log</a> ]"; | ||
| echo "</div>"; | ||
|
|
||
| #echo "<pre>"; | ||
| #print_r($GLOBALS); | ||
| #echo "</pre>"; | ||
| echo "</body>\n</html>"; | ||
|
|
||
| } | ||
|
|
||
|
|
||
| function dbconnect(){ | ||
|
|
||
| mysql_connect("localhost","aquarion","DBPASSWORD") | ||
| or die ("<h1>Problem connecting to MySQL</h1>"); | ||
| mysql_select_db("afphrid") or fuckup($PHP_AUTH_USER, $PHP_SELF, "MySQL", "All your database are belong to someone else.", mysql_error()); | ||
| } | ||
|
|
||
|
|
||
| function safequery($query){ | ||
| $result = mysql_query($query) | ||
| or sqlerror($query, mysql_error()); | ||
| return $result; | ||
| } | ||
|
|
||
| function logthis($user, $category, $log_simple, $log_detailed){ | ||
| $timestamp=date("YmdHis"); | ||
| $log_detailed = addslashes($log_detailed); | ||
| $query = "insert into translog "; | ||
| $query .="(user, category, log_simple, log_detailed, timestamp)"; | ||
| $query .=" values "; | ||
| $query .="('$user', '$category', '$log_simple', '$log_detailed', '$timestamp')"; | ||
| mysql_query($query) or die($query . "<br>" . mysql_error()); | ||
| } | ||
|
|
||
| function sqlerror($query,$error){ | ||
| panic("<B>Error</B><br>\nSomething strange and magical has happened, Aquarion has been notified."); | ||
| logthis("mysql", "error", "mysql error", "<pre>$query</pre> <B>resulted in:</B><br> $error"); | ||
| } | ||
|
|
||
| function panic($message) { | ||
| echo "<div style=\"background-color: #CCFFCC\">\n"; | ||
| echo "<H2>PANIC!</H2>"; | ||
| echo " $message\n"; | ||
| echo "</div></td>\n"; | ||
| } | ||
|
|
||
|
|
||
| function cleanstring($string){ | ||
| $string = strip_tags($string); | ||
| $string = addslashes($string); | ||
| return $string; | ||
| } | ||
|
|
||
| function authenticate($realm) | ||
| { | ||
| HEADER("WWW-Authenticate: Basic realm=\"$realm\""); | ||
| HEADER("HTTP/1.0 401 Unauthorized"); | ||
| build_header("Invalid Password"); | ||
| echo "<h1>Invalid Password</h1>\n"; | ||
| echo "<p>Um, That doesn't seem to be 100% accurate. Please try again, or get an <a href=\"newuser.php\">account</a></p>\n"; | ||
| build_footer("Authentication"); | ||
| die(); | ||
| } | ||
|
|
||
| // Authenticate User for this domain | ||
| function login($who) { | ||
|
|
||
| // Has the user logged in? | ||
| if (empty($_SERVER['PHP_AUTH_USER'])) | ||
| { | ||
| authenticate("Afphrid"); // No? Log them in. | ||
| } | ||
| else // Yup. | ||
| { | ||
| if ($who == "Any"){ | ||
| $query = "select * from person where "; | ||
| $query .= "password = password('{$_SERVER['PHP_AUTH_PW']}') "; | ||
| $query .= "and '{$_SERVER['PHP_AUTH_USER']}' IN (name)"; | ||
| } else { | ||
| $query = "select * from person where "; | ||
| $query .= "password = password('{$_SERVER['PHP_AUTH_PW']}') "; | ||
| $query .= "and '$who' IN (name)"; | ||
| } | ||
|
|
||
| $result = safequery($query); | ||
| if (mysql_num_rows($result)==0) // Do the username & Password match? | ||
| { | ||
| authenticate("Afphrid User") ; // Nope? Panic! | ||
| } | ||
|
|
||
| return mysql_fetch_array($result); | ||
| } | ||
| } | ||
|
|
||
| function sendmessage($to, $user, $subject, $message, $type){ | ||
| // Types: | ||
| // mom message (internal person-person message) | ||
| // mor relation (relationship requested/confirmed/denied/deleted) | ||
| // moc cliques (clique requests) | ||
| // moca cliqueacc (clique accepts/denials) | ||
| // mou upgrade (Afphrid Upgrade / Announcement) | ||
| // mob bugreport (Mail on Bugreport) | ||
|
|
||
|
|
||
| if ($to == 0 && $type != "mou"){ | ||
| $to = mysql_fetch_array(safequery("select * from person where id = 1")); | ||
| } else { | ||
| $to = mysql_fetch_array(safequery("select * from person where id = $to")); | ||
| } | ||
| $types = array( | ||
| "mom" => "someone sends you a message", | ||
| "mor" => "someone relates to you", | ||
| "moc" => "something happens in your clique", | ||
| "moca" => "you are accepted into a clique", | ||
| "mou" => "afprhid is upgraded", | ||
| "mob" => "someone files a bug" | ||
| ); | ||
|
|
||
| // Status | ||
| // 0 Unread | ||
| // 1 Read | ||
| // 2 Filed | ||
|
|
||
| #insert into message (msgto, msgfrom, subject, content, datesent, status) | ||
| #values (1, 41, "This is a test", "This is really a test", NOW(), 0); | ||
|
|
||
| if (strstr($to['prefs'], "-".$type."-")){ | ||
| $content = "Heya, This is Aquarion's Afphrid2 system. Someone has sent " | ||
| ."a message I thought you should be aware of (okay, it's because you" | ||
| ." asked to be notified when ".$types[$type].". Here is the message:\n" | ||
| ."\n" | ||
| .stripslashes($message)."\n\n" | ||
| ."You can deal with this now by going to <http://www.afphrid.org.uk>/" | ||
| ."where you can also request to stop getting these messages :-) \n" | ||
| ."\n\tYours in total sincerity,\n\n\t\tAfphrid" | ||
| ."\n\t\tPP. Aquarion De'Blue\n\n-- \nAre you afphrid of the database?\n" | ||
| ."http://www.afphrid.org.uk"; | ||
|
|
||
| $content = wordwrap($content); | ||
|
|
||
| mail($to['email'], "[AFPHRID] ".$subject, $content, | ||
| "From: site@afphrid.org.uk\r\nX-Mailer: Afphrid/v2"); | ||
|
|
||
| #echo "<pre>$content\n\nSent</pre>"; | ||
|
|
||
| logthis($to['name'], "Message", "Sent a message & email about \"".$subject."\"", $content); | ||
| } elseif ($type = "email"){ | ||
| $content = "Heya, This is Aquarion's Afphrid2 system sending you an email.\n" | ||
| .stripslashes($message)."\n\n" | ||
| ."Message Ends.\n\n\tYours in total sincerity,\n\n\t\tAfphrid" | ||
| ."\n\t\tPP. Aquarion De'Blue\n\n-- \nAre you afphrid of the database?\n" | ||
| ."http://www.afphrid.org.uk/"; | ||
|
|
||
| $content = wordwrap(strip_tags($content)); | ||
|
|
||
| mail($to['email'], "[AFPHRID] ".$subject, $content, | ||
| "From: afphrid@aquarionics.com\r\nX-Mailer: Afphrid/v2"); | ||
|
|
||
| #echo "<pre>$content\n\nSent</pre>"; | ||
|
|
||
| logthis($to['name'], "Message", "Sent a message & email about \"".$subject."\"", $content); | ||
| } else { | ||
| logthis($to['name'], "Message", "Sent a message about \"".$subject."\"", $message); | ||
| } | ||
|
|
||
| $q = "insert into message " | ||
| ."(msgto, msgfrom, subject, content, datesent, status, type)" | ||
| ." values " | ||
| ."(".$to['id'].", ".$user.", \"".$subject | ||
| ."\", \"".strip_tags(wordwrap($message))."\", NOW(), 0, \"".$type."\")"; | ||
|
|
||
| safequery($q); | ||
|
|
||
| } | ||
|
|
||
| ?> |
| @@ -0,0 +1,125 @@ | ||
| <?PHP | ||
| /* | ||
| Afphrid 1.5 | ||
| File: userfuncs.php | ||
| Purpose: Useful functions for playing with users | ||
| Dates: C: 5/6/02 M: 5/6/02 | ||
| Author: Nicholas 'Aquarion' Avenell | ||
| Changes: | ||
| */ | ||
|
|
||
| function validate_name($name){ | ||
| $test = ""; | ||
|
|
||
| // Test Null Username | ||
|
|
||
| if ($name == "") | ||
| { | ||
| $test .= "<li> Username field was blank, This is required.</li>\n"; | ||
| } | ||
|
|
||
| //Test Existing Username | ||
|
|
||
| $result = safequery("select * from person where name = '".addslashes($name)."'"); | ||
| if(mysql_num_rows($result)>0) | ||
| { | ||
| $test .= "<li>That username is already in use. Sorry.</li>"; | ||
| } | ||
|
|
||
|
|
||
| return $test; | ||
| } | ||
|
|
||
|
|
||
| function validate_email($email){ | ||
| $test = ""; | ||
| if ($email == "" || $email == "user@domain") | ||
| { | ||
| $test .="<li>Email may not be null. (Email addresses "; | ||
| $test .="are purely for admin, they will never be displayed)</li>"; | ||
| } | ||
|
|
||
| $result = safequery("select name from person where email = '".addslashes($email)."'"); | ||
| if(mysql_num_rows($result)>0) | ||
| { | ||
| $row = mysql_fetch_array($result); | ||
| $test .= "<li>A person (".$row['name'].") with that email address (".$email; | ||
| $test .= ") is already registered. Sorry.</li>"; | ||
| } | ||
|
|
||
| if ( !eregi("^[\.A-Za-z0-9\_-]+@[A-Za-z0-9\_-]+.[A-Za-z0-9\_-]+.*", $email)) | ||
| { | ||
| $test .= "<li>$email does not look like an email address to me.</li>"; | ||
| } | ||
|
|
||
| if ( eregi("^[\.A-Za-z0-9\_-]+@lspace.org", $email)) | ||
| { | ||
| echo "<li>Oooh, An L-Space person. *honoured*</li>"; | ||
| } | ||
|
|
||
| if ( eregi("^[\.A-Za-z0-9\_-]+@hotmail.com", $email)) | ||
| { | ||
| echo "<li>You do realise that that email address contaminates the database with evil, don't you?</li>"; | ||
| } | ||
|
|
||
| if ( eregi("^.*spam.*", $email)) | ||
| { | ||
| echo "<li>Er, I hope that address is valid. You don't really need to spamtrap it, you know, it's only ever used for sending email, and never shown on screen. Still, you can always change it later... (This doesn't affect the validation, it's just a warning)</li>"; | ||
| } | ||
|
|
||
|
|
||
| return $test; | ||
| } | ||
|
|
||
|
|
||
| function validate_homepage($homepage){ | ||
| $test = ""; | ||
|
|
||
| if ($homepage=="http://" || $homepage=="") | ||
| { | ||
| // don't do anything | ||
| } | ||
| else | ||
| { | ||
| if (!ereg("^http://.*", $homepage)) | ||
| { | ||
| $test .= "<li>Home pages have to start 'http://', otherwise the links are broken.</li>"; | ||
| } | ||
| } | ||
| return $test; | ||
| } | ||
|
|
||
|
|
||
| function validate_password($password, $second_password, $action){ | ||
| $test = ""; | ||
| if ($action == "modify"){ | ||
| if ($password == ""){ | ||
| echo "<li>Not changing Password</li>"; | ||
| } else { | ||
| if ($second_password == ""){ | ||
| $test .= "<li>You didn't confirm your new password, Why?</li>"; | ||
| } else { | ||
| if ($password != $second_password){ | ||
| $test .= "<li>Your passwords didn't match. Wanna try again?</li>"; | ||
| } | ||
| } | ||
| } | ||
| }else{ | ||
| if ($password == ""){ | ||
| $test .= "<li>Please choose a password</li>"; | ||
| } else { | ||
|
|
||
| if ($second_password == ""){ | ||
| $test .= "<li>You didn't confirm your password, Why?</li>"; | ||
| } else { | ||
| if ($password != $second_password){ | ||
| $test .= "<li>Your passwords didn't match. Wanna try again?</li>"; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| return $test; | ||
| } |
| @@ -0,0 +1,88 @@ | ||
| <?PHP | ||
| /* | ||
| Afphrid 1.5 | ||
| File: index.php | ||
| Purpose: Front page & Portal | ||
| Dates: C: 5/3/02 M: 2002-05-30 | ||
| Author: Nicholas 'Aquarion' Avenell | ||
| Changes: | ||
| */ | ||
| include("include/library.php"); // Useful Functions | ||
|
|
||
| build_header("Front Page"); | ||
|
|
||
| dbconnect(); | ||
|
|
||
| ?> | ||
| <div class="rightmenu"> | ||
| <h2>Afphrid</h2> | ||
| <a href="newuser.php">Become a member</a><br> | ||
| <a href="user.php">Login</a><br> | ||
| <a href="notes.php">View Help</a><br> | ||
| <a href="stats.php">Statistics</a> | ||
| </div> | ||
|
|
||
| <h1>YOU DO NOT NEED A NEW ACCOUNT, YOUR OLD AFPHRID ACCOUNT IS STILL HERE!</h1> | ||
| <p> | ||
| If you can't remember your username, it'll be listed in the <a href="view.php">view section (which no longer requires login)</a>. | ||
| </p> | ||
| <h2>Forgot Password?</h2> | ||
|
|
||
| <?PHP | ||
| html_form_start("recoverpassword", "forgotpassword.php"); | ||
| echo "<LABEL for=\"id\" class=\"label\">To:"; | ||
| $result = safequery("select id, name from person order by name"); | ||
| echo "<select name=\"id\" id=\"id\">\n"; | ||
| echo "<option value=\"0\">--- Select username ---</option>\n"; | ||
| while ($row=mysql_fetch_array($result)){ | ||
| echo "\t<option value=\"".$row['id']."\">".$row['name']."</option>\n"; | ||
| } | ||
| echo "</select>\n"; | ||
| echo "</LABEL>"; | ||
|
|
||
| $buttons = array( | ||
| #array (Label, Name, Button type) | ||
| array ('Recover Pasword', 'recover', 'submit'), | ||
| ); | ||
|
|
||
| html_buttons($buttons); | ||
|
|
||
| html_form_close(); | ||
|
|
||
| /*---------+------------------+------+-----+---------+----------------+ | ||
| | Field | Type | Null | Key | Default | Extra | | ||
| +----------+------------------+------+-----+---------+----------------+ | ||
| | id | int(10) unsigned | | PRI | NULL | auto_increment | | ||
| | msgto | int(11) | YES | | NULL | | | ||
| | msgfrom | int(11) | YES | | NULL | | | ||
| | subject | tinytext | YES | | NULL | | | ||
| | content | mediumtext | YES | | NULL | | | ||
| | datesent | timestamp(12) | YES | | NULL | | | ||
| | status | int(11) | YES | | NULL | | | ||
| | type | tinytext | YES | | NULL | | | ||
| +----------+------------------+------+-----+---------+---------------*/ | ||
|
|
||
| #$rssData = parseRSS("http://www.aquarionics.com/meta/category/afphrid.rss2"); | ||
| $rssData = array(); | ||
| array_shift($rssData); | ||
| $rss = array(); | ||
| foreach ( $rssData as $item ) | ||
| { | ||
| echo "<div class=\"news_box\">"; | ||
| echo "<h2 class=\"news_headline\">".$item['title']."</h2>"; | ||
| echo "<p>".$item['content:encoded']."</p>"; | ||
| echo "<div class=\"news_footer\">".$item['dc:date']." - <a href=\"message.php?compose=1\">Aquarion</a></div>"; | ||
| echo "</div>"; | ||
|
|
||
| echo "<br>"; | ||
|
|
||
| } | ||
|
|
||
| ?> | ||
|
|
||
| <?PHP | ||
| build_footer("Front Page"); | ||
| ?> |
| @@ -0,0 +1,230 @@ | ||
| <?PHP | ||
| // Afphrid Messages System | ||
| // Aquarion, 2002-05-31 | ||
|
|
||
| include("include/library.php"); | ||
| dbconnect(); | ||
| $user = login("Any"); | ||
|
|
||
|
|
||
| $PHP_SELF = $_SERVER['PHP_SELF']; | ||
|
|
||
| build_header($user['name']."'s messages page"); | ||
|
|
||
| if (isset($_GET['view'])){ | ||
|
|
||
| $q = "select *, message.id as ident from message, person where" | ||
| ." message.id = ".$_GET['view']." and person.id = msgto" | ||
| ." and msgto = ".$user['id']; | ||
|
|
||
| $r = safequery($q); | ||
|
|
||
| if (mysql_num_rows($r) == 0){ | ||
| echo "Message Not Found, or invalid."; | ||
| } else { | ||
|
|
||
| $message = mysql_fetch_array($r); | ||
|
|
||
| if ($message['status'] == 0){ | ||
| safequery("update message set status = 1 where id = ".$_GET['view']); | ||
| } | ||
|
|
||
| html_heading("Viewing Message", 1,""); | ||
| html_form_start("message", $_SERVER['PHP_SELF']."?folder=".$_GET['folder']); | ||
| html_hidden("id", $message['ident']); | ||
|
|
||
|
|
||
| echo "<LABEL for=\"to\">To:" | ||
| ."<span id=\"to\">".$user['name']."</span></LABEL><br>"; | ||
|
|
||
| html_lesshidden("to", "From", $message['msgfrom'], $message['name']); | ||
| #echo "<LABEL for=\"from\"><div class=\"label\">From:</div>" | ||
| # ."<span id=\"from\">".$message['name']."</span></LABEL><br>"; | ||
|
|
||
| echo "<br>"; | ||
|
|
||
| html_lesshidden("subject", "Subject", "Re: ".$message['subject'], $message['subject']); | ||
| #echo "<LABEL for=\"subject\"><div class=\"label\">Subject:</div>" | ||
| # ."<span id=\"subject\">".$message['subject']."</span></LABEL><br>"; | ||
| echo "<br>"; | ||
| echo "<LABEL for=\"content\">Content:" | ||
| ."<code id=\"content\">" | ||
| . nl2br($message['content']) | ||
| ."</code></LABEL><br>"; | ||
|
|
||
| html_hidden("message", $message['content']); | ||
|
|
||
| $buttons = array( | ||
| #array (Label, Name, Button type) | ||
| array ('Mark Unread', 'unread', 'submit'), | ||
| array ('Delete Message', 'delete', 'submit'), | ||
| array ('File Message', 'file', 'submit'), | ||
| array ('Reply', 'reply', 'submit') | ||
| ); | ||
|
|
||
| html_buttons($buttons); | ||
| html_form_close(); | ||
| } | ||
|
|
||
| } elseif (isset($_GET['compose'])){ | ||
| html_form_start("message", $_SERVER['PHP_SELF']); | ||
|
|
||
| echo "<LABEL for=\"to\">To:"; | ||
|
|
||
| $result = safequery("select id, name from person where id != ".$user['id']." order by name"); | ||
| echo "<select name=\"to\">\n"; | ||
| while ($row=mysql_fetch_array($result)){ | ||
| if ($_GET['compose'] == $row['id']){ | ||
| $checked = " checked"; | ||
| } else { | ||
| $checked = ""; | ||
| } | ||
| echo "\t<option value=\"".$row['id']."\"".$checked | ||
| .">".$row['name']."</option>\n"; | ||
|
|
||
| } | ||
| echo "</select>\n"; | ||
|
|
||
| echo "</LABEL>"; | ||
| echo "<br>"; | ||
| html_lesshidden("from", "From", $user['id'], $user['name']); | ||
| echo "<br>"; | ||
| html_textbox("subject", "Subject:", 255, ""); | ||
| echo "<br>"; | ||
| html_textarea("message", "Message", 10, 70, ""); | ||
| echo "<br>"; | ||
| $buttons = array( | ||
| #array (Label, Name, Button type) | ||
| array ('Post', 'post', 'submit'), | ||
| array ('Cancel', 'cancel', 'submit') | ||
| ); | ||
|
|
||
| html_buttons($buttons); | ||
| html_form_close(); | ||
|
|
||
| } elseif (isset($_POST['reply'])){ | ||
| html_form_start("message", $_SERVER['PHP_SELF']); | ||
|
|
||
| echo "<LABEL for=\"to\"><div class=\"label\">To:</div>"; | ||
|
|
||
| $result = safequery("select id, name from person order by name"); | ||
| echo "<select name=\"to\">\n"; | ||
| while ($row=mysql_fetch_array($result)){ | ||
| if ($row['id'] == $_POST['to']){ | ||
| $checked = " selected"; | ||
| } else { | ||
| $checked = ""; | ||
| } | ||
| echo "\t<option value=\"".$row['id']."\"" | ||
| .$checked.">".$row['name']."</option>\n"; | ||
| } | ||
| echo "</select>\n"; | ||
|
|
||
| echo "</LABEL>"; | ||
| echo "<br>"; | ||
| html_lesshidden("from", "from", $user['id'], $user['name']); | ||
| echo "<br>"; | ||
| html_textbox("subject", "Subject:", 255, $_POST['subject']); | ||
| echo "<br>"; | ||
|
|
||
| $reply = "----I got this message:----\n" | ||
| .stripslashes($_POST['message']) | ||
| ."\n--------------------------\n"; | ||
|
|
||
| html_textarea("message", "Message", 10, 70, $reply); | ||
| echo "<br>"; | ||
| $buttons = array( | ||
| #array (Label, Name, Button type) | ||
| array ('Post', 'post', 'submit'), | ||
| array ('Cancel', 'cancel', 'submit') | ||
| ); | ||
|
|
||
| html_buttons($buttons); | ||
| html_form_close(); | ||
|
|
||
| } elseif (isset($_POST['post'])){ | ||
|
|
||
| $msg = strip_tags($_POST['message']); | ||
| sendmessage($_POST['to'], $user['id'], $_POST['subject'], $msg, "mom"); | ||
|
|
||
| } elseif (isset($_POST['delete'])){ | ||
|
|
||
| safequery("delete from message where msgto = " | ||
| .$user['id']." and id = ".$_POST['id']); | ||
|
|
||
| } elseif (isset($_POST['file'])){ | ||
|
|
||
| safequery("update message set status = 2 where msgto = " | ||
| .$user['id']." and id = ".$_POST['id']); | ||
|
|
||
| } elseif (isset($_POST['unread'])){ | ||
|
|
||
| safequery("update message set status = 0 where msgto = " | ||
| .$user['id']." and id = ".$_POST['id']); | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
| if (isset($_GET['folder'])){ | ||
| $folder = $_GET['folder']; | ||
| } else { | ||
| $folder = false; | ||
| } | ||
|
|
||
| if ($folder == "filed") { | ||
| $box = "Filed"; | ||
| $stat = 2; | ||
| } elseif ($folder == "read") { | ||
| $box = "Read Messages"; | ||
| $stat = 1; | ||
| } else { | ||
| $folder = "inbox"; | ||
| $box = "Inbox"; | ||
| $stat = 0; | ||
| } | ||
|
|
||
| /*---------+------------------+------+-----+---------+----------------+ | ||
| | Field | Type | Null | Key | Default | Extra | | ||
| +----------+------------------+------+-----+---------+----------------+ | ||
| | id | int(10) unsigned | | PRI | NULL | auto_increment | | ||
| | msgto | int(11) | YES | | NULL | | | ||
| | msgfrom | int(11) | YES | | NULL | | | ||
| | subject | tinytext | YES | | NULL | | | ||
| | content | mediumtext | YES | | NULL | | | ||
| | datesent | timestamp(12) | YES | | NULL | | | ||
| | status | int(11) | YES | | NULL | | | ||
| | type | tinytext | YES | | NULL | | | ||
| +----------+------------------+------+-----+---------+---------------*/ | ||
|
|
||
| html_heading($box, 1,""); | ||
| echo "[ <a href=\"message.php?compose=mail\">Compose New Message</a> ]<br>"; | ||
| echo "View [ <a href=\"message.php?folder=inbox\">Inbox</a> " | ||
| ."| <a href=\"message.php?folder=read\">Read Messages</a> " | ||
| ."| <a href=\"message.php?folder=filed\">Filed</a> " | ||
| ."]<br>"; | ||
|
|
||
| $q = "select message.id as ident, name, msgfrom, subject, date_format(datesent,'%W, %M %D %Y %k:%i') AS nicedate from message, person where status = $stat and msgto = ".$user['id']." and person.id = msgfrom" ; | ||
| $r = safequery($q); | ||
|
|
||
| echo "<table width=\"80%\">\n"; | ||
|
|
||
| echo "<tr><th> </th><th>From</th><th>Subject</th><th>Date</th></tr>\n"; | ||
|
|
||
| while($row = mysql_fetch_array($r)){ | ||
| echo "<tr>"; | ||
| echo "<td><img src=\"images/letter.png\" width=\"32\"" | ||
| ."height=\"24\" border=0 alt=\"A Message\"></td>"; | ||
|
|
||
| echo "<td>".$row['name']."</td>"; | ||
| echo "<td><a href=\"message.php?view=".$row['ident'] | ||
| ."&folder=$folder\">".$row['subject']."</a></td>"; | ||
| echo "<td>".$row['nicedate']."</td>"; | ||
|
|
||
| echo "</tr>\n"; | ||
| } | ||
|
|
||
| echo "</table>\n"; | ||
|
|
||
| build_footer("Messages"); | ||
| ?> |
| @@ -0,0 +1,57 @@ | ||
| <?PHP | ||
| header("content-type: text/plain"); | ||
| /* | ||
| mysql> describe cliquelink; | ||
| +----------+----------+------+-----+---------+----------------+ | ||
| | Field | Type | Null | Key | Default | Extra | | ||
| +----------+----------+------+-----+---------+----------------+ | ||
| | id | int(11) | | PRI | NULL | auto_increment | | ||
| | name | tinytext | | | | | | ||
| | clique | tinytext | | | | | | ||
| | position | tinytext | | | | | | ||
| +----------+----------+------+-----+---------+----------------+ | ||
| 4 rows in set (0.00 sec) | ||
| mysql> describe clique; | ||
| +-------------+--------------+------+-----+---------+----------------+ | ||
| | Field | Type | Null | Key | Default | Extra | | ||
| +-------------+--------------+------+-----+---------+----------------+ | ||
| | id | int(11) | | PRI | NULL | auto_increment | | ||
| | name | varchar(255) | | | | | | ||
| | owner | tinytext | YES | | NULL | | | ||
| | status | int(11) | | | 0 | | | ||
| | description | tinytext | | | | | | ||
| +-------------+--------------+------+-----+---------+----------------+ | ||
| 5 rows in set (0.04 sec) | ||
| */ | ||
|
|
||
| ?> | ||
| drop table cliquelink; | ||
|
|
||
| CREATE TABLE cliquelink ( | ||
| id int(11) NOT NULL auto_increment, | ||
| user int NOT NULL, | ||
| clique int NOT NULL, | ||
| position tinytext NOT NULL, | ||
| PRIMARY KEY (id) | ||
| ) TYPE=MyISAM; | ||
|
|
||
| <?PHP | ||
| include("include/library.php"); | ||
| dbconnect(); | ||
|
|
||
| $q = "select person.id as cl_person, clique.id as cl_clique," | ||
| ." person.name as username, clique.name as cliquename, position" | ||
| ." from cliquelink, person, clique" | ||
| ." where (person.name = cliquelink.name)" | ||
| ." and (clique.name = cliquelink.clique) order by person.id"; | ||
|
|
||
| $r = safequery($q); | ||
|
|
||
| while ($row = mysql_fetch_array($r)){ | ||
| #echo "# ".$row['username']." is ".$row['position']." of ".$row['cliquename']."\n"; | ||
| echo "insert into cliquelink (user, clique, position) values (" | ||
| .$row['cl_person'].", ".$row['cl_clique'].", \"".addslashes($row['position'])."\");\n"; | ||
| } | ||
| ?> |
| @@ -0,0 +1,58 @@ | ||
| <?PHP | ||
| include("include/library.inc"); // Useful functions | ||
| include("include/diary.inc"); // Diary Stuff | ||
| dbconnect(); | ||
| build_header("misc", "Index", "."); | ||
|
|
||
| ?> | ||
|
|
||
| <div class="menu"> | ||
| <h2>Misc Stuff</h2> | ||
|
|
||
| <a href="/chat/">Chat</a><br> | ||
|
|
||
| </div> | ||
|
|
||
| <div id="content"> | ||
| <h1>Misc Stuff</h1> | ||
| <P>This is where everything else goes, all the stuff that's here but doesn't warrent it's own section. | ||
|
|
||
| <p> | ||
| <ul> | ||
| <li><a href="misc/mods/">Mad Toonz</a> Music by Aquarion. | ||
| <li><a href="misc/story/">Forever</a> Contiuous Multibranching Story | ||
| <li><a href="/meets">Misc meet reports & stuff</a> | ||
| <li><a href="/nsd">NSD</a> - Almost daily thing. will return. | ||
| <li><a href="/quoth">Quoth</a> - VB-based Quote generator, unsupported | ||
| <li><a href="/terra">Terra Incognita</a> - Scifi E-Zine, will also return | ||
| <li><a href="/chat">Chat</a> - Java based IRC | ||
| <li><a href="/fun">Fun</a> - Other, single, misc Stuff™ | ||
| </ul> | ||
|
|
||
| <h2>The Vault</h2> | ||
| The Vault is the home for all the websites I've done for other places that are now homeless, much of this was on Aquarionics back in 2000, but never made it to the new servers. Well, it's here now :-) | ||
|
|
||
| <dl> | ||
| <dt><a href="/misc/vault/diary/">Diary</a> | ||
| <dd>My diary for January to Febuary 2000. The archives for March -> April are lost right up until I started using Blogger, which is where the current Journal archives take up. | ||
|
|
||
| <dt><a href="/misc/vault/joscars/">Joscars</a> | ||
| <dd>For one night only, the residents of #eddings were showered with awards by <a href="http://www.extraverse.org">Joy Green</a>, and here is the official website once more :) | ||
|
|
||
| <dt><a href="/misc/vault/top5/">Top 5</a> | ||
| <dd>My original games review/preview section, Second generation. Of the games in here, one was canned totally (DK3) another took another two years to release (StS3D) and more were just constantly delayed. | ||
|
|
||
| <dt><a href="/misc/vault/craig/">Craig's Page Of Colours</a> | ||
| <dd>I haven't seen Craig for ages, but four years ago I helped him create this, and so it remains here until he complains :-) | ||
|
|
||
| <dt><a href="/misc/vault/roses/">Roses</a> | ||
| <dd>The results of a bored lunchtime in Mascalls. | ||
|
|
||
| <dt><a href="/misc/vault/greyscale/">Greyscale</a> | ||
| <dd>My Black & White Fan-zine ran for seven issues over four months, with another two months beforehand as a normal website. The archives of this, once thought lost forever, are now here. | ||
| </dl> | ||
| <?PHP | ||
| echo "© Nicholas 'Aquarion' Avenell 1999 to ". date("Y") . " inclusive. Do you realise you are person "; | ||
| include("include/counter.inc"); | ||
| echo " to visit this page?</div>"; | ||
| ?> |
| @@ -0,0 +1,290 @@ | ||
| <?PHP | ||
| /* | ||
| * New Relationship | ||
| * | ||
| * | ||
| * | ||
| * | ||
| */ | ||
|
|
||
| function confirm($id){ | ||
| global $user; | ||
| $q = "select * from relationship, person as p1, person as p2 where " | ||
| ."relationship.id = $id and p1.id = person_one and p2.id = person_two"; | ||
| $r = safequery($q); | ||
| $rel = mysql_fetch_array($r); | ||
|
|
||
| if (mysql_num_rows($r) == 0){ | ||
| echo "<h2>No</h2>\n<p>This relationship does not exist"; | ||
| } elseif ($rel['person_two'] != $user['id']){ | ||
| echo "<h2>No</h2>\n<p>Confirming this relationship has nothing to do with you."; | ||
| echo $rel['person_two'] ." != ". $user['id']; | ||
| } else { | ||
| $q = "update relationship set status = 2 where id = $id"; | ||
| safequery($q); | ||
| echo "<p>Confirmed this relationship."; | ||
|
|
||
| $subject = $user['name']." confirmed your relationship"; | ||
| $msg = $user['name']." confirmed your relationship, you are now " | ||
| .$user['name']."'s ".$rel['rel_twoone']." and you are their " | ||
| .$rel['rel_onetwo'].".\nHave a nice day :-)"; | ||
|
|
||
| sendmessage($rel['person_one'], 0, $subject, $msg, "mor"); | ||
|
|
||
| logthis($user['name'], "Relationship", $user['name'] . " Confirmed rel id ". $id, $q); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| function deny($id){ | ||
| global $user; | ||
| $q = "select * from relationship, person as p1, person as p2 where " | ||
| ."relationship.id = $id and p1.id = person_one and p2.id = person_two"; | ||
| $r = safequery($q); | ||
| $rel = mysql_fetch_array($r); | ||
|
|
||
| if (mysql_num_rows($r) == 0){ | ||
| echo "<h2>No</h2>\n<p>This relationship does not exist"; | ||
| } elseif ($rel['person_two'] != $user['id']){ | ||
| echo "<h2>No</h2>\n<p>Denying this relationship has nothing to do with you."; | ||
| echo $rel['person_two'] ." != ". $user['id']; | ||
| } else { | ||
| $q = "update relationship set status = 0 where id = $id"; | ||
| safequery($q); | ||
| echo "<p>Denied this relationship."; | ||
| $subject = $user['name']." denied your relationship"; | ||
| $msg = $user['name']." denied your relationship, as " | ||
| .$rel['rel_twoone']." and ".$rel['rel_onetwo'] | ||
| .".\nSorry :-|"; | ||
|
|
||
| sendmessage($rel['person_one'], 0, $subject, $msg, "mor"); | ||
| logthis($user['name'], "Relationship", $user['name'] . " Denied rel id ". $id, $q); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| function validate_exists($var, $label){ | ||
| $message = ""; | ||
| $var = rtrim($var); | ||
| if (empty($var)){ | ||
| $message .= "\t<li>$label is required</li>"; | ||
| } | ||
| return $message; | ||
|
|
||
| } | ||
|
|
||
| function validate_user($id){ | ||
| $message = ""; | ||
| if (empty($id)){ | ||
| $message .= "\t<li>No User ID? Something strange and magical has happened</li>"; | ||
| } | ||
| return $message; | ||
|
|
||
| } | ||
|
|
||
| function validate_relationship($two, $one){ | ||
| $message = ""; | ||
| if (empty($two)){ | ||
| $message .= "\t<li>No Second Party? Something strange and magical has happened</li>"; | ||
| } elseif ($two == $one){ | ||
| $message .= "\t<li>You can't relate to yourself, it makes you go blind.</li>"; | ||
| } elseif ($two == 0){ | ||
| $message .= "\t<li>Afphrid is a psudouser, you can't relate to it.</li>"; | ||
| } elseif ($two == 8){ | ||
| $message .= "\t<li>I'm sorry, but <a href=\"http://www.aquarionics.com/index.php?id=438\">no</a></li>"; | ||
| } else{ | ||
| $q = "select id from relationship where (person_one = $one and " | ||
| ."person_two = $two) or (person_two = $one and person_one = $two)"; | ||
| $r = mysql_num_rows(safequery($q)); | ||
|
|
||
| if ($r != 0){ | ||
| echo "\t<li>Er, not to cast judgement on your lifestyle, you " | ||
| ."understand, but you are already related to this person " | ||
| ."at least once. This isn't going to stop it going in the " | ||
| ."database, but just to make sure you're aware :-)</li>"; | ||
| } | ||
| } | ||
| return $message; | ||
| } | ||
|
|
||
| function showform($defaults){ | ||
| html_form_start("newrelationship", $_SERVER['PHP_SELF']); | ||
|
|
||
| // Note: It would be a terribly good idea to validate user names | ||
| // before touching this function with a barge pole. | ||
|
|
||
|
|
||
| #$defaults = array(person_one, person_two, rel_onetwo, rel_twoone) | ||
|
|
||
| // Box 'o users | ||
| $users = array(); | ||
| $result = safequery("select id, name from person order by name"); | ||
| while ($row=mysql_fetch_array($result)){ | ||
| $users[$row['id']] = $row['name']; | ||
| } | ||
|
|
||
| // Hidden, Yet labeled. Thus LessHidden :-) | ||
| html_lesshidden("name", "First Party:", $defaults[0], $users[$defaults[0]]); | ||
|
|
||
| echo "<br>"; | ||
|
|
||
| // As much as I hate specific solutions, | ||
| // A bespoke function to display a drop-box of users. | ||
| echo "<LABEL for=\"person_two\"><div class=\"label\">Second Party:</div>"; | ||
| echo " <select name=\"person_two\">\n"; | ||
| foreach ($users as $id => $name){ | ||
| if ($id == $defaults[1]){ | ||
| $selected = " selected"; | ||
| } else { | ||
| $selected = ""; | ||
| } | ||
| echo "\t<option value=\"".$id."\"".$selected.">".$name."</option>\n"; | ||
| } | ||
| echo "</select>\n"; | ||
| echo "</LABEL><br>"; | ||
|
|
||
| html_textbox("rel_onetwo", "Relationship of 1 to 2:", "225", $defaults[2]); | ||
| echo "<br>"; | ||
|
|
||
| html_textbox("rel_twoone", "Relationship of 2 to 1:", "225", $defaults[3]); | ||
| echo "<br>"; | ||
|
|
||
| $buttons = array( | ||
| #array (Label, Name, Button type) | ||
| array ('Resubmit', 'resubmit', 'submit'), | ||
| array ('Reset Form', 'reset', 'reset') | ||
| ); | ||
|
|
||
| html_buttons($buttons); | ||
|
|
||
| echo "<p>ie, "; | ||
| echo $users[$defaults[0]]." is ".$users[$defaults[1]]."'s ".$defaults[2] | ||
| ." and ".$users[$defaults[1]]." is ".$users[$defaults[0]]."'s " | ||
| .$defaults[3]."</p>"; | ||
|
|
||
|
|
||
| html_form_close(); | ||
| } // End Showform | ||
|
|
||
|
|
||
|
|
||
| include("include/library.php"); | ||
| dbconnect(); | ||
| $user = login("Any"); | ||
| include("include/userfuncs.php"); | ||
| build_header("New Relationship"); | ||
|
|
||
| echo "<H1>New Relationship</H1>"; | ||
|
|
||
| if (isset($_GET['action'])){ | ||
| #echo "Action detected"; | ||
| switch ($_GET['action']){ | ||
|
|
||
| case "confirm": | ||
| if (isset($_GET['id'])){ | ||
| #echo "Confirm detected"; | ||
| confirm($_GET['id']); | ||
| } else { | ||
| echo "<h2>Confirm</h2>"; | ||
| echo "<p>No ID Specified. Sod off</p>"; | ||
| } | ||
| break; | ||
| // break | ||
|
|
||
| case "deny": | ||
| if (isset($_GET['id'])){ | ||
| #echo "Confirm detected"; | ||
| deny($_GET['id']); | ||
| } else { | ||
| echo "<h2>Deny</h2>"; | ||
| echo "<p>No ID Specified. Sod off</p>"; | ||
| } | ||
| break; | ||
| // break | ||
|
|
||
| } | ||
| } else { | ||
|
|
||
| $defaults = array($user['id'], $_POST['person_two'], $_POST['rel_onetwo'], $_POST['rel_twoone']); | ||
|
|
||
| echo "<ul>\n"; | ||
|
|
||
| $validate = validate_user($user['id']); | ||
| $validate .= validate_relationship($_POST['person_two'], $user['id']); | ||
| $validate .= validate_exists($_POST['rel_onetwo'], "Relationship part one"); | ||
| $validate .= validate_exists($_POST['rel_twoone'], "Relationship part two"); | ||
|
|
||
| echo $validate."</ul>\n\n"; | ||
|
|
||
| if ($validate == ""){ | ||
| if (isset($_POST['confirm'])){ | ||
| $q = "insert into relationship " | ||
| ."(person_one, person_two, rel_onetwo, rel_twoone, status) values " | ||
| ."(".$defaults[0].", ".$defaults[1].", \"".$defaults[2]."\", \"".$defaults[3]."\", 1)"; | ||
|
|
||
| $subject = $user['name']." has requested a relationship"; | ||
| $msg = $user['name']." has requested a relationship where they are" | ||
| ." your ".$defaults[3]. " and you are their ".$defaults[2] | ||
| .". Please go to your user page and confirm or deny this."; | ||
|
|
||
| sendmessage($defaults[1], 0, $subject, $msg, "mor"); | ||
|
|
||
| logthis($user['name'], "Relationship", $user['name'] . " related to id ". $defaults[1], $q); | ||
|
|
||
| safequery($q); | ||
|
|
||
| html_heading("Confirmed", "2", ""); | ||
|
|
||
| echo "<p>Congratulations, that appears to have gone off without a hitch.</p>"; | ||
|
|
||
| html_heading("What happens now?", "3", ""); | ||
|
|
||
| echo "<p>The relationship is in the Database as \"Unconfirmed\", which " | ||
| ."basically means that I'm waiting for the other side to admit to it." | ||
| //."<br>If they asked me too, I will have sent an email to them " | ||
| //."asking to come to the site and confirm it. Most people have opted" // Commented out until the messaging system is in. | ||
| //." for this." | ||
| ." When they do, they can just click \"Confirm\" on their" | ||
| ." user page, and it'll start being included in the main views. "; | ||
|
|
||
| } else { | ||
| echo "<p>No serious problems found, which is cool. You can now confirm " | ||
| ."the relationship (click Confirm) or you have one last chance to " | ||
| ."fix any spelling errors or anything in the box far below.</p>"; | ||
|
|
||
| html_heading("Confirm:", "3", ""); | ||
| html_form_start("newrelationship", $_SERVER['PHP_SELF']); | ||
| $users = array(); | ||
| $result = safequery("select id, name from person where id = " | ||
| .$defaults[1]." or id = ".$defaults[0]." order by name"); | ||
|
|
||
| while ($row=mysql_fetch_array($result)){ | ||
| $users[$row['id']] = $row['name']; | ||
| } | ||
| echo $users[$defaults[0]]." is ".$users[$defaults[1]]."'s ".$defaults[2] | ||
| ." and ".$users[$defaults[1]]." is ".$users[$defaults[0]]."'s " | ||
| .$defaults[3]."</p>"; | ||
|
|
||
| html_hidden("person_two", $defaults[1]); | ||
| html_hidden("rel_onetwo", $defaults[2]); | ||
| html_hidden("rel_twoone", $defaults[3]); | ||
|
|
||
| $buttons = array( | ||
| #array (Label, Name, Button type) | ||
| array ('Confirm', 'confirm', 'submit') | ||
| ); | ||
|
|
||
| html_buttons($buttons); | ||
|
|
||
| html_form_close(); | ||
|
|
||
| html_heading("Correct:", "3", ""); | ||
| showform($defaults); | ||
| } | ||
| } else { | ||
| html_heading("Please correct:", "3", ""); | ||
| showform($defaults); | ||
| } | ||
|
|
||
| } | ||
| build_footer("New Relationship"); |
| @@ -0,0 +1,205 @@ | ||
| <?PHP | ||
| /* | ||
| Afphrid 1.5 | ||
| File: newuser.php | ||
| Purpose: Add new user to the database | ||
| Dates: C: 5/4/02 M: 5/6/02 | ||
| Author: Nicholas 'Aquarion' Avenell | ||
| Changes: | ||
| */ | ||
| include("include/library.php"); | ||
| include("include/userfuncs.php"); | ||
| build_header("Add New User"); | ||
| dbconnect(); | ||
|
|
||
| /* | ||
| mysql> describe person; | ||
| +------------+--------------+------+-----+---------+----------------+ | ||
| | Field | Type | Null | Key | Default | Extra | | ||
| +------------+--------------+------+-----+---------+----------------+ | ||
| | name | varchar(255) | | | | | | ||
| | email | tinytext | YES | | NULL | | | ||
| | homepage | tinytext | YES | | NULL | | | ||
| | password | tinytext | YES | | NULL | | | ||
| | registered | date | YES | | NULL | | | ||
| | prefs | tinytext | YES | | NULL | | | ||
| | id | int(11) | | PRI | NULL | auto_increment | | ||
| +------------+--------------+------+-----+---------+----------------+ | ||
| */ | ||
|
|
||
| function showform($defaults){ | ||
|
|
||
| html_form_start("newuser", $_SERVER['PHP_SELF']); | ||
|
|
||
| echo "<h1>Become a member of Afphrid</h1>\n"; | ||
|
|
||
| // html_textbox($name, $label, $maxlength, $default) | ||
|
|
||
| echo "<p>If you already have an account here, and are creating a new " | ||
| ."one because you've lost the details of the old one, don't, " | ||
| ."It buggers up the stats, data quality, and views something " | ||
| ."cronic. Instead, email afphrid@aquarionics.com (If that bounces, " | ||
| ."there will be a better address on <a href=\"http://www.aquarionics" | ||
| .".com\">Aquarionics</a> for me, or whatever email address I last po" | ||
| ."sted to AFP from) and I will reset password or email addy for you" | ||
| .". Thanks. -- Aquarion, Admin"; | ||
|
|
||
| echo "<p>"; | ||
| html_textbox("name", "Name:", 255, $defaults[0]); | ||
| echo "<br>This will be your login name, and the name people select" | ||
| ." to relate to you"; | ||
|
|
||
| echo "</p>\n\n<p>"; | ||
|
|
||
| html_textbox("email", "Email Address:", 255, $defaults[1]); | ||
| echo "<br>Never displayed on screen, this is where messages and replacement" | ||
| ." passwords are sent"; | ||
|
|
||
| echo "</p>\n\n<p>"; | ||
|
|
||
| html_textbox("homepage", "Web Link:", 255, $defaults[2]); | ||
| echo "<br>Home Page, <a href=\"http://www.lspace.org/fandom" | ||
| ."/afp/a-files/\" target=\"outside\">A-Files</a> or " | ||
| ."<a href=\"http://sanity.klijmij.net/irc/\" target=\"outside\">" | ||
| ."IRC Gallery</a> entry (both links open in new window)"; | ||
|
|
||
| echo "</p>\n\n<p>"; | ||
|
|
||
| html_password("password", "Enter desired password:"); | ||
| newrow(); | ||
| html_password("confirm_pw", "Re-enter Password to confirm"); | ||
| echo "<br>Your password, which will be encrypted. Passwords are not " | ||
| ."recoverable, but new ones can be generated and emailed to you."; | ||
|
|
||
| echo "</p>\n\n<p>"; | ||
|
|
||
| // chkbox($name, $label, $checked) | ||
| echo "e-mail me when..."; | ||
| newrow(); | ||
| html_chkbox("mor", "...I have new relationships", $defaults[3]); | ||
| newrow(); | ||
| html_chkbox("moc", "...people join my clique", $defaults[4]); | ||
| newrow(); | ||
| html_chkbox("mom", "...people send me messages", $defaults[5]); | ||
| newrow(); | ||
| html_chkbox("moca", "...I'm accepted into cliques", $defaults[6]); | ||
| newrow(); | ||
| html_chkbox("mou", "...AFPhrid is upgraded", $defaults[7]); | ||
| newrow(); | ||
|
|
||
| echo "(either way, Afphrid's messaging system will send you a message, this" | ||
| ." just chooses which messages are emailed to you also)"; | ||
|
|
||
| echo "</p>"; | ||
| $buttons = array( | ||
| #array (Label, Name, Button type) | ||
| array ('Add User', 'submit', 'submit'), | ||
| array ('Reset Form', 'reset', 'reset') | ||
| ); | ||
|
|
||
| html_buttons($buttons); | ||
|
|
||
|
|
||
| html_form_close(); | ||
| } | ||
|
|
||
| if (isset($_REQUEST['submit'])){ | ||
|
|
||
| $validate = ""; | ||
|
|
||
| echo "<ul>"; | ||
|
|
||
| $validate .= validate_name($_REQUEST['name']); | ||
| $validate .= validate_email($_REQUEST['email']); | ||
| $validate .= validate_homepage($_REQUEST['homepage']); | ||
| $validate .= validate_password($_REQUEST['password'], $_REQUEST['confirm_pw'], "new"); | ||
|
|
||
| echo $validate; | ||
|
|
||
| echo "</ul>"; | ||
| $valid_submits = array("name", "password", "email", "homepage", | ||
| "mor", "moc", "mom", "moca", "mou"); | ||
|
|
||
| foreach($valid_submits as $submit){ | ||
| if (isset($_POST["$submit"])){ | ||
| $$submit = $_POST["$submit"]; | ||
| } else { | ||
| $$submit = false; | ||
| } | ||
| } | ||
|
|
||
| if ($validate == ""){ | ||
|
|
||
| echo "<H2>Woo Hoo! Passed!</H2>"; | ||
| echo "<p>Well, that all seems to be in order, it's time to" | ||
| ." put you in the database then. A little warning first," | ||
| ." This is a database of AFPRelations, not real ones." | ||
| ." Although I am not going to activly seek out and destroy" | ||
| ." all real relationships on the database, I'd really " | ||
| ." prefer it if they wern't put in here. There are reasons," | ||
| ." and if you ask, I shall tell you them. But not here.</p>\n"; | ||
|
|
||
| echo "<p>Right, lets see about getting you in here then...</p>"; | ||
|
|
||
| $av_prefs = array('mor', 'moc', 'mom', 'moca', 'mou'); | ||
| $myprefs = "-"; | ||
|
|
||
| foreach ($av_prefs as $thispref){ | ||
| if ($$thispref){ | ||
| $myprefs .= $thispref ."-"; | ||
| #echo "$thispref on<br>"; | ||
| } | ||
| } | ||
|
|
||
| #echo "Prefs: ". $myprefs ."<br>"; | ||
|
|
||
| $registered = date("Y-m-d"); | ||
|
|
||
| $name = cleanstring($name); | ||
| $email = cleanstring($email); | ||
| if ($homepage == "http://"){$homepage = "";} | ||
| $homepage = cleanstring($homepage); | ||
| $password = cleanstring($password); | ||
|
|
||
|
|
||
|
|
||
| $query = "insert into person "; | ||
| $query .= "(name, email, homepage, password, registered, prefs)"; | ||
| $query .= " values "; | ||
| $query .= "('$name', '$email', '$homepage', password('$password'), '$registered', '$myprefs')"; | ||
|
|
||
| safequery($query); | ||
| #panic("Not doing that, It's only a beta!<br>".$query); | ||
| logthis($name, "newuser", $name . " joined the database", $query); | ||
|
|
||
| echo "<p>Done. You are now a member of Afphrid, Go forth and " | ||
| ."<a href=\"user.php\">log in</a>"; | ||
|
|
||
|
|
||
| } else { | ||
| echo "<H2>Failed. Bad.</H2>"; | ||
|
|
||
| $defaults = array($name, $email, $homepage, $mor, $moc, $mom, $moca, $mou); | ||
| showform($defaults); | ||
| } | ||
|
|
||
|
|
||
| }else{ | ||
|
|
||
| $defaults = array("", "user@domain", "http://", false, false, false, false, false); | ||
| showform($defaults); | ||
|
|
||
| } | ||
|
|
||
| function newrow(){ | ||
| echo "<br>\n"; | ||
| } | ||
|
|
||
|
|
||
| build_footer("New User"); | ||
| ?> |
| @@ -0,0 +1,59 @@ | ||
| <?PHP | ||
| ////////////////////////////////////////////////////////// | ||
| // Title: Notes Page | ||
| // Project: AFPhrid (Alt.fan.pratchett heroic relational & impossible database) | ||
| // Description: | ||
| // | ||
| // Authour: Nicholas Avenell | ||
| // Date: | ||
|
|
||
| include("include/library.php"); // Useful Functions | ||
|
|
||
| build_header("Notes on the system"); | ||
|
|
||
| ?> | ||
| <h1>Help and Notes</h1> | ||
| <h1>Relationships</h1> | ||
| <blockquote> | ||
| <p>Every relationship consits of five bits of data. The two parties involved, the relationships between the parties (No, there is no singuler there. One person is another's AFPBrother, so the other person is an AFPSister. They have to be differant) and a Status. The Status is either 1, Unconfirmed or 2, Confirmed.</p> | ||
| <h2>Confirmations</h2> | ||
| <p>To be listed on the main page, and in the reports and all associated fun and games, you must be a <i>confirmed</i> relationship. This simply means that the side that didn't attempt to start the relationship has to click a little button on his or her User Page (Next to the relationship) that says "yes". Or "No". Depending. This stops people claiming relationships that don't exist.</p> | ||
|
|
||
| </blockquote> | ||
|
|
||
| <h1>Groups/Cliques</h1> | ||
| <blockquote> | ||
| <p>Cliques (AKA Groups) are relationships with more than one person in them. Anybody can create them, and if they are marked "Open", then anybody can join them too. If they arn't set as Open, each new member must be moderated by the club's creator.</p> | ||
| <h2>Moderation for Members</h2> | ||
| <p>When you apply to join a group, a message and, preferance depending, an email will be sent to the moderator for that group. You just have to wait until they decide to either let you in or not.</p> | ||
| <h2>Moderation for Moderators</h2> | ||
| <p>For every person who applys to be part of your clique you will get a a message and, preferance depending, an email. The message will give you two links, one for confirming the membership, one for denying it with a prompt for a reason, which will be sent to the prospective member.</p> | ||
| </blockquote> | ||
|
|
||
| <h1>User Information</h1> | ||
| <blockquote> | ||
| <p>Email addresses are used to send out forgotten passwords. They are never displayed on screen as full valid email addresses (At the very least, they will be formatted as "user-at-domain-dot-tld"). We will not sell your addresses to spammers. I do not need to lose friends that badly.</p> | ||
| <p>New passwords are generated by the system and sent to the address you registered with. </p> | ||
| <p><i>Aquarion, Nor any person who is working on any part of the system at any time, cannot get at your password. Your password is MD5 encrypted. We *cannot* decrypt it, and would not even if we could. We work out authentication by encrypting your answer and comparing it with the database. We can't know what your password is. Kay?</i> | ||
| </p> | ||
| </blockquote> | ||
|
|
||
| <h1>What we can get for you.</h1> | ||
| <blockquote> | ||
| We can undelete the following:<br> | ||
| <ul> | ||
| <li>Relationships | ||
| <li>Relationships | ||
| </ul> | ||
| That's it :-)<br> | ||
| Messages deleted are lost forever, as are clique memberships and users (see next question). They are gone when you say so. if you delete a relationship by accident, send Aquarion a message and he will get back to you with more information. | ||
| </blockquote> | ||
|
|
||
| <h1>How do I leave the database?</h1> | ||
| <blockquote> | ||
| You can't.<br> | ||
| Well, we don't want you to. There *is* a way, which severs all relationships, leaves all cliques, deletes all data, and all in all removes all traces of your existance, but we don't want you to use it. The facility is only there because it *should* be. Why would you want to? It's for *fun*. Don't take it that seriously.<br> | ||
| Note: This is *not* for merging two accounts together, if you want to that then shout at Aquarion.<br> | ||
| But, because people might find it necessary, you can get rid of yourself by going to this page here: <a href="delete.php">Delete</a>. | ||
| </blockquote> | ||
| <? build_footer("Notes on the System") ?> |
| @@ -0,0 +1,82 @@ | ||
| body { | ||
| margin: 0 0 0 0; | ||
| padding: 0 0 0 0; | ||
| font-family: sans-serif; | ||
| } | ||
| #header { | ||
| background: #840000 url("images/barback.gif") repeat-x; | ||
| height: 147px; | ||
| text-align: center; | ||
| margin: 0 0 0 0; | ||
| padding: 0 0 0 0; | ||
| } | ||
| .menubar { | ||
| background-color: #808080; | ||
| border-top: #404040 solid 3px; | ||
| border-bottom: #404040 solid 3px; | ||
| text-align: right; | ||
| } | ||
|
|
||
| .menubar { | ||
| background-color: #808080; | ||
| border-top: #404040 solid 3px; | ||
| border-bottom: #404040 solid 3px; | ||
| text-align: right; | ||
|
|
||
| } | ||
|
|
||
|
|
||
| .label{ | ||
| width: 200px; | ||
| text-align: right; | ||
| display: inline; | ||
| vertical-align: top; | ||
| margin-right: 3px; | ||
| } | ||
|
|
||
| .completed{ | ||
| color: gray; | ||
| } | ||
|
|
||
| a { | ||
| text-decoration: none; | ||
| font-weight: bold; | ||
| color: #009A00; | ||
| } | ||
|
|
||
| a.barlink { | ||
| text-decoration: none; | ||
| font-weight: bold; | ||
| color: #D9D9D9; | ||
| } | ||
|
|
||
| a:hover { | ||
| color: #FFFFFF; | ||
| text-decoration: none; | ||
| background: #009A00; | ||
| } | ||
|
|
||
| input, select, textarea { | ||
| border: 1px solid #009A00; | ||
| color: #000000; | ||
| background: #B6ECB6; | ||
| } | ||
|
|
||
| div.rightmenu { | ||
| border: 1px solid #000000; | ||
| color: #000000; | ||
| width: 150px; | ||
| float: right; | ||
| padding: 10px 10px 10px 10px; | ||
| margin: 10px 10px 10px 10px; | ||
| } | ||
|
|
||
| dt { font-weight: bold; } | ||
|
|
||
| dd { margin-bottom: 10px; } | ||
|
|
||
| .news_box {border: solid black 1px; background: #C0C0C0; margin-left: 10%; margin-right: 10%;} | ||
|
|
||
| .news_headline {margin: 0 0 0 0; border-bottom: solid black 1px;} | ||
|
|
||
| .news_footer {margin: 0 0 0 0; border-top: solid black 1px; text-align: right;} |
| @@ -0,0 +1,16 @@ | ||
| <?PHP | ||
| /* | ||
| * | ||
| * | ||
| * | ||
| * | ||
| * | ||
| */ | ||
| include("../include/library.php"); | ||
| dbconnect(); | ||
| $user = login("Aquarion"); | ||
| build_header("View Log"); | ||
| echo "<H1>Admin</H1>"; | ||
|
|
||
|
|
||
| build_footer("View Log"); |
| @@ -0,0 +1,58 @@ | ||
| <?PHP | ||
| include("../include/library.php"); | ||
| dbconnect(); | ||
| $user = login("Aquarion"); | ||
| build_header("News"); | ||
| echo "<H1>View Stuff</H1>"; | ||
|
|
||
|
|
||
| $me = $_SERVER['PHP_SELF']; | ||
|
|
||
| if(isset($_POST['post'])){ | ||
|
|
||
| echo "<h2>Sending Messages...</h2>\n"; | ||
|
|
||
| if ($_POST['post'] == "Post to all"){ | ||
|
|
||
| $q = "select id, name from person where LOCATE('mou', prefs) != 0;"; | ||
| $r = safequery($q); | ||
| $msg = $_POST['message']; | ||
|
|
||
| while ($row = mysql_fetch_array($r)){ | ||
| #sendmessage($to, $user, $subject, $message, $type) | ||
| sendmessage($row['id'], 0, $_POST['subject'], $msg, "mou"); | ||
| echo "Sent message to ".$row['name']."<br>\n"; | ||
| } | ||
|
|
||
| } else { | ||
| sendmessage(0, 1, $_POST['subject'], $_POST['message'], "mou"); | ||
| } | ||
| } else{ | ||
| html_form_start("message", $_SERVER['PHP_SELF']); | ||
|
|
||
| echo "To: Everyone"; | ||
|
|
||
| echo "<br>"; | ||
| html_lesshidden("from", "From", $user['id'], $user['name']); | ||
| echo "<br>"; | ||
| html_textbox("subject", "Subject:", 255, ""); | ||
| echo "<br>"; | ||
| html_textarea("message", "Message", 10, 70, ""); | ||
| echo "<br>"; | ||
| $buttons = array( | ||
| #array (Label, Name, Button type) | ||
| array ('Post to all', 'post', 'submit'), | ||
| array ('Site Only', 'post', 'submit'), | ||
| array ('Cancel', 'cancel', 'submit') | ||
| ); | ||
|
|
||
| html_buttons($buttons); | ||
| html_form_close(); | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
| build_footer("News"); | ||
| ?> |
| @@ -0,0 +1,3 @@ | ||
| <?PHP | ||
| header("location: ../user.php"); | ||
| ?> |
| @@ -0,0 +1,164 @@ | ||
| <?PHP | ||
| include("../include/library.php"); | ||
| dbconnect(); | ||
| $user = login("Aquarion"); | ||
| build_header("View Stuff"); | ||
| echo "<H1>View Stuff</H1>"; | ||
|
|
||
| if (!isset($_GET['view'])){ | ||
|
|
||
| $me = $_SERVER['PHP_SELF']; | ||
|
|
||
| echo "<h1>View What?</h1>"; | ||
| echo "People: " | ||
| ."[ <a href=\"$me?view=people&type=new\">New</a> " | ||
| ."| <a href=\"$me?view=people&type=all\">All</a> " | ||
| ."]<br>"; | ||
|
|
||
| echo "Relationships: " | ||
| ."[ <a href=\"$me?view=rels&type=unconfirmed\">Unconfirmed</a> " | ||
| ."| <a href=\"$me?view=rels&type=dead\">Dead</a> " | ||
| ."| <a href=\"$me?view=rels&type=confirmed\">Confirmed</a> " | ||
| ."| <a href=\"$me?view=rels&type=all\">All</a> " | ||
| ."]<br>"; | ||
| echo "Cliques: [ Summary | Members | Processing ]<br>"; | ||
| echo "Log: [ <a href=\"view_log.php\">Transactions</a> ]"; | ||
|
|
||
| } else { | ||
|
|
||
|
|
||
|
|
||
| switch ($_GET['view']){ | ||
|
|
||
| case "people": | ||
|
|
||
| switch ($_GET['type']){ | ||
|
|
||
| case "new": | ||
|
|
||
| $q = "select id, name, email, homepage, " | ||
| ."date_format(registered,'%W, %M %D %Y %k:%i') AS nicedate, prefs " | ||
| ."from person order by registered desc limit 30"; | ||
|
|
||
| break; // End New | ||
|
|
||
| default: | ||
|
|
||
| $q = "select id, name, email, homepage, " | ||
| ."date_format(registered,'%W, %M %D %Y %k:%i') AS nicedate, prefs " | ||
| ."from person order by id asc"; | ||
|
|
||
| break; // End New | ||
| } | ||
|
|
||
| $r = safequery($q); | ||
|
|
||
| echo "<table>\n"; | ||
|
|
||
| echo "<tr><th>ID</th><th>Name</th><th>E-Mail</th><th>Web</th><th>Joined</th></tr>\n"; | ||
|
|
||
| while ($row = mysql_fetch_array($r)){ | ||
| echo "<tr>"; | ||
| echo "<td>".$row['id']."</td>"; | ||
| echo "<td><a href=\"view_log.php?where=user&equals=" | ||
| .$row['name']."\">".$row['name']."</a></td>"; | ||
|
|
||
| echo "<td><a href=\"mailto:".$row['email']."\">".$row['email']."</a></td>"; | ||
| echo "<td><a href=\"".$row['homepage']."\">".$row['homepage']."</a></td>"; | ||
| echo "<td>".$row['nicedate']."</td>"; | ||
| echo "</tr>\n"; | ||
| } | ||
|
|
||
| echo "</table>\n"; | ||
|
|
||
| break; // End People | ||
|
|
||
| case "rels": | ||
|
|
||
| switch ($_GET['type']){ | ||
| /*-----------+----------+------+-----+---------+----------------+ | ||
| | Field | Type | Null | Key | Default | Extra | | ||
| +------------+----------+------+-----+---------+----------------+ | ||
| | id | int(11) | | PRI | NULL | auto_increment | | ||
| | person_one | int(11) | | | 0 | | | ||
| | person_two | int(11) | | | 0 | | | ||
| | rel_onetwo | tinytext | | | | | | ||
| | rel_twoone | tinytext | | | | | | ||
| | status | int(11) | YES | | NULL | | | ||
| +------------+----------+------+-----+---------+---------------*/ | ||
|
|
||
| case "confirmed": | ||
|
|
||
| $q = "select relationship.id, p1.name as one, p2.name as two, rel_onetwo, " | ||
| ."rel_twoone from relationship, person as p1, person as p2 " | ||
| ."where (p1.id = relationship.person_one) and " | ||
| ."(p2.id = relationship.person_two) " | ||
| ."and status = 2;"; | ||
|
|
||
| break; // End New | ||
|
|
||
| case "unconfirmed": | ||
|
|
||
| $q = "select status, relationship.id, p1.name as one, p2.name as two," | ||
| ." rel_onetwo, rel_twoone from relationship, person as p1," | ||
| ." person as p2 where (p1.id = relationship.person_one) and " | ||
| ."(p2.id = relationship.person_two) " | ||
| ."and status = 1;"; | ||
|
|
||
| break; // End New | ||
|
|
||
| case "dead": | ||
|
|
||
| $q = "select status, relationship.id, p1.name as one, p2.name as two," | ||
| ." rel_onetwo, rel_twoone from relationship, person as p1," | ||
| ." person as p2 where (p1.id = relationship.person_one) and " | ||
| ."(p2.id = relationship.person_two) " | ||
| ."and status = 0;"; | ||
|
|
||
| break; // End New | ||
|
|
||
| default: | ||
|
|
||
| $q = "select status, relationship.id, p1.name as one, p2.name as two," | ||
| ." rel_onetwo, rel_twoone from relationship, person as p1," | ||
| ." person as p2 where (p1.id = relationship.person_one) and " | ||
| ."(p2.id = relationship.person_two) "; | ||
| #."and status = 0;"; | ||
|
|
||
| break; // End New | ||
| } | ||
|
|
||
| #die($q); | ||
| $r = safequery($q); | ||
| echo "<h2>Relationships where status is ".$_GET['type']."</h2>"; | ||
| echo "<table>\n"; | ||
|
|
||
| echo "<tr><th>ID</th><th>One</th><th>One->Two</th><th>Two</th>" | ||
| ."<th>Two-One</th><th>One</th><th>Status</th></tr>\n"; | ||
|
|
||
| while ($row = mysql_fetch_array($r)){ | ||
| echo "<tr>"; | ||
| echo "<td>".$row['id']."</td>"; | ||
| echo "<td>".$row['one']."</td>"; | ||
| echo "<td>".$row['rel_onetwo']."</td>"; | ||
| echo "<td>".$row['two']."</td>"; | ||
| echo "<td>".$row['rel_twoone']."</td>"; | ||
| echo "<td>".$row['one']."</td>"; | ||
| echo "<td>".$row['status']."</td>"; | ||
| echo "</tr>\n"; | ||
| } | ||
|
|
||
| echo "</table>\n"; | ||
|
|
||
|
|
||
| break; // End Relationships | ||
|
|
||
| }// end switch ($_GET['view']) | ||
|
|
||
|
|
||
| } // end (!isset($_GET['view']) | ||
|
|
||
|
|
||
|
|
||
| build_footer("View"); | ||
| ?> |
| @@ -0,0 +1,127 @@ | ||
| <?PHP | ||
| // Variables: | ||
|
|
||
| if (isset($_REQUEST['id'])){ | ||
| $id = $_REQUEST['id']; | ||
| } else { | ||
| $id = false; | ||
| } | ||
|
|
||
| if (isset($_REQUEST['where'])){ | ||
| $where = $_REQUEST['where']; | ||
| } else { | ||
| $where = false; | ||
| } | ||
|
|
||
| if (isset($_REQUEST['equals'])){ | ||
| $equals = $_REQUEST['equals']; | ||
| } else { | ||
| $equals = false; | ||
| } | ||
|
|
||
| $PHP_SELF = $_SERVER['PHP_SELF']; | ||
|
|
||
| $requeststring = ""; | ||
|
|
||
|
|
||
| if (empty($step)){ | ||
| $step = 40; // Default limits for how many records displayed at once. | ||
| } | ||
| if (empty($from)){ | ||
| $from = 0; // Start at zero if no better offer | ||
| }; | ||
| $to = $from + $step; | ||
|
|
||
|
|
||
|
|
||
| include("../include/library.php"); | ||
| dbconnect(); | ||
| $user = login("Aquarion"); | ||
| build_header("View Log"); | ||
| echo "<H1>Transaction Log</H1>"; | ||
|
|
||
|
|
||
| #Transaction Display | ||
| if ($id){ | ||
| echo "<H2>Details for transaction $id</H2>"; | ||
| $query = "select *, date_format(timestamp,'%Y-%m-%d/%T') AS nicedate from translog where id = '$id'"; | ||
| } else { | ||
| echo "<H2>Details for latest transaction</H2>"; | ||
| $query = "select *, date_format(timestamp,'%Y-%m-%d/%T') AS nicedate from translog order by id desc limit 1"; | ||
| } | ||
| $result = safequery($query); | ||
| $trans = mysql_fetch_array($result); | ||
| echo "<table>\n"; | ||
| echo "<tr><th>Date:</th><td style=\"text-align: left\">" . $trans['nicedate'] . "</td></tr>\n"; | ||
| echo "<tr><th>User:</th><td style=\"text-align: left\">" . $trans['user'] . "</td></tr>\n"; | ||
| echo "<tr><th>Action:</th><td style=\"text-align: left\">" . $trans['log_simple'] . "</td></tr>\n"; | ||
| echo "<tr><th>Details:</th><td style=\"text-align: left\">" . $trans['log_detailed'] . "</td></tr>\n"; | ||
| echo "</table>\n"; | ||
|
|
||
| #End Transaction Display | ||
|
|
||
| $query = "select *, date_format(timestamp,'%Y-%m-%d/%T') AS nicedate from translog"; | ||
| if ($where && $equals) { | ||
| $query .=" where ". $where ." = '". $equals ."'"; | ||
| $requeststring.="&where=$where&equals=$equals"; | ||
| } | ||
| $query .=" order by timestamp desc"; | ||
|
|
||
| $result = safequery($query . " limit $from, $to"); | ||
| echo "<table>"; | ||
| echo "<tr><th>Trans. ID</th><th>Date & Time</th><th>Login</th><th>Transaction</th><th></th></tr>"; | ||
| while($row = mysql_fetch_array($result)){ | ||
| echo "<tr><td>"; | ||
| echo $row['id'] | ||
| . "</td><td>" | ||
| . $row['nicedate'] | ||
| . "</td><td><a href=\"$PHP_SELF?where=user&equals=" | ||
| . $row['user'] | ||
| . "\">" | ||
| . $row['user'] | ||
| . "</a></td><td>" | ||
| . $row['log_simple'] | ||
| . "</td><td class=\"extra\"> "; | ||
| if (!empty($row['log_detailed'])){ | ||
| echo "[<A HREF=\"?id=".$row['id']."&step=$step" | ||
| ."&from=$from$requeststring\">View Details</A>]"; | ||
| } | ||
| echo "</td></tr>"; | ||
| } | ||
|
|
||
| echo "</table>"; | ||
|
|
||
| echo "[<A HREF=\"$PHP_SELF\">Reset filters</A>] "; | ||
|
|
||
| /* | ||
| Building next and previous buttons | ||
| */ | ||
| $records = mysql_num_rows(safequery($query)); | ||
| $prevfrom = $from - $step; | ||
| $prevto = $from; | ||
|
|
||
| if ($from > 0) { // If there are results behind us... | ||
| echo "[<A HREF=\"$PHP_SELF?from=$prevfrom&to=$prevto$requeststring&step=$step\">Back $step</A>] "; | ||
| } | ||
|
|
||
| $nextfrom = $to; | ||
| $nextto = $to + $step; | ||
| if ($nextfrom < $records){ // There may be records ahead... | ||
| if ($nextto > $records) { | ||
| $set = $records - $to; | ||
| } else { | ||
| $set = $step; | ||
| } | ||
| echo "[<A HREF=\"$PHP_SELF?from=$nextfrom&to=$nextto$requeststring&step=$step\">Next $set</A>]"; | ||
| } | ||
| echo "<br>\n" // Options for setting the Step limit | ||
| ."Blocks of <A HREF=\"$PHP_SELF?step=20$requeststring\">20</A> " | ||
| ."<A HREF=\"$PHP_SELF?step=50$requeststring\">50</A> " | ||
| ."<A HREF=\"$PHP_SELF?step=100$requeststring\">100</A> " | ||
| ."<A HREF=\"$PHP_SELF?step=200$requeststring\">200</A> " | ||
| ."<A HREF=\"$PHP_SELF?step=500$requeststring\">500</A> " | ||
| ."<A HREF=\"$PHP_SELF?step=1000$requeststring\">1000</A> "; | ||
| #."<A HREF=\"$PHP_SELF?step=10000$requeststring\">10000</A> " // *ahem* 10000 is a little far. | ||
|
|
||
| build_footer("View Log"); | ||
| ?> |
| @@ -0,0 +1,375 @@ | ||
| <?PHP | ||
| /* | ||
| * New Relationship | ||
| * | ||
| * | ||
| * | ||
| * | ||
| */ | ||
|
|
||
| function confirm($id){ | ||
| global $user; | ||
| $q = "select * from relationship, person as p1, person as p2 where " | ||
| ."relationship.id = $id and p1.id = person_one and p2.id = person_two"; | ||
| $r = safequery($q); | ||
| $rel = mysql_fetch_array($r); | ||
|
|
||
| if (mysql_num_rows($r) == 0){ | ||
| echo "<h2>No</h2>\n<p>This relationship does not exist"; | ||
| } elseif ($rel['person_two'] != $user['id']){ | ||
| echo "<h2>No</h2>\n<p>Confirming this relationship has nothing to do with you."; | ||
| echo $rel['person_two'] ." != ". $user['id']; | ||
| } else { | ||
| $q = "update relationship set status = 2 where id = $id"; | ||
| safequery($q); | ||
| echo "<p>Confirmed this relationship."; | ||
|
|
||
| #Note, You, at this point, are Person One | ||
|
|
||
| $subject = $user['name']." confirmed your relationship"; | ||
| $msg = $user['name']." confirmed your relationship, you are now " | ||
| .$user['name']."'s ".$rel['rel_twoone']." and you are their " | ||
| .$rel['rel_onetwo'].".\nHave a nice day :-)"; | ||
|
|
||
| sendmessage($rel['person_one'], 0, $subject, $msg, "mor"); | ||
|
|
||
| logthis($user['name'], "Relationship", $user['name'] . " Confirmed rel id ". $id, $q); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| function modify($id, $onetwo, $twoone){ | ||
| /* NOTE! Doesn't work! Find some way of making sure the right person | ||
| confirms it?*/ | ||
| global $user; | ||
| $q = "select * from relationship, person as p1, person as p2 where " | ||
| ."relationship.id = $id and p1.id = person_one and p2.id = person_two"; | ||
| $r = safequery($q); | ||
| $rel = mysql_fetch_array($r); | ||
|
|
||
| if (mysql_num_rows($r) == 0){ | ||
| echo "<h2>No</h2>\n<p>This relationship does not exist"; | ||
| } elseif ($rel['person_two'] != $user['id'] && $rel['person_one'] != $user['id']){ | ||
| echo "<h2>No</h2>\n<p>Deleting this relationship has nothing to do with you."; | ||
| } else { | ||
| $q = "update relationship set status = 1, rel_twoone = \"" | ||
| .$twoone."\", rel_onetwo = \"".$onetwo."\" where id = $id"; | ||
|
|
||
| safequery($q); | ||
| echo "<p>Modified this relationship. (It's been set as Unconfirmed until the other side accepts this)"; | ||
| $subject = $user['name']." modified your relationship"; | ||
| $msg = $user['name']." modified your relationship, to " | ||
| .$rel['rel_twoone']." and ".$rel['rel_onetwo'] | ||
| .".\n, It is now set as Unconfirmed again until you agree"; | ||
|
|
||
| sendmessage($rel['person_one'], 0, $subject, $msg, "mor"); | ||
| logthis($user['name'], "Relationship", $user['name'] | ||
| . " modified rel id ". $id, $q); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| function derelate($id){ | ||
| global $user; | ||
| $q = "select * from relationship, person as p1, person as p2 where " | ||
| ."relationship.id = $id and p1.id = person_one and p2.id = person_two"; | ||
| $r = safequery($q); | ||
| $rel = mysql_fetch_array($r); | ||
|
|
||
| if (mysql_num_rows($r) == 0){ | ||
| echo "<h2>No</h2>\n<p>This relationship does not exist"; | ||
| } elseif ($rel['person_two'] != $user['id'] && $rel['person_one'] != $user['id']){ | ||
| echo "<h2>No</h2>\n<p>Deleting this relationship has nothing to do with you."; | ||
| } else { | ||
| $q = "update relationship set status = 0 where id = $id"; | ||
| safequery($q); | ||
| echo "<p>Denied this relationship."; | ||
| $subject = $user['name']." deleted your relationship"; | ||
| $msg = $user['name']." deleted your relationship, as " | ||
| .$rel['rel_twoone']." and ".$rel['rel_onetwo'] | ||
| .".\nSorry :-|"; | ||
|
|
||
| sendmessage($rel['person_one'], 0, $subject, $msg, "mor"); | ||
| logthis($user['name'], "Relationship", $user['name'] . " Deleted rel id ". $id, $q); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| function deny($id){ | ||
| global $user; | ||
| $q = "select * from relationship, person as p1, person as p2 where " | ||
| ."relationship.id = $id and p1.id = person_one and p2.id = person_two"; | ||
| $r = safequery($q); | ||
| $rel = mysql_fetch_array($r); | ||
|
|
||
| if (mysql_num_rows($r) == 0){ | ||
| echo "<h2>No</h2>\n<p>This relationship does not exist"; | ||
| } elseif ($rel['person_two'] != $user['id']){ | ||
| echo "<h2>No</h2>\n<p>Denying this relationship has nothing to do with you."; | ||
| } else { | ||
| $q = "update relationship set status = 0 where id = $id"; | ||
| safequery($q); | ||
| echo "<p>Denied this relationship."; | ||
| $subject = $user['name']." denied your relationship"; | ||
| $msg = $user['name']." denied your relationship, as " | ||
| .$rel['rel_onetwo']." and ".$rel['rel_twoone'] | ||
| .".\nSorry :-|"; | ||
|
|
||
| sendmessage($rel['person_one'], 0, $subject, $msg, "mor"); | ||
| logthis($user['name'], "Relationship", $user['name'] . " Denied rel id ". $id, $q); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| function validate_exists($var, $label){ | ||
| $message = ""; | ||
| $var = rtrim($var); | ||
| if (empty($var)){ | ||
| $message .= "\t<li>$label is required</li>"; | ||
| } | ||
| return $message; | ||
|
|
||
| } | ||
|
|
||
| function validate_user($id){ | ||
| $message = ""; | ||
| if (empty($id)){ | ||
| $message .= "\t<li>No User ID? Something strange and magical has happened</li>"; | ||
| } | ||
| return $message; | ||
|
|
||
| } | ||
|
|
||
| function validate_relationship($two, $one){ | ||
| $message = ""; | ||
| if ($two == 0){ | ||
| $message .= "\t<li>Afphrid is a psudouser, you can't relate to it.</li>"; | ||
| } elseif ($two == $one){ | ||
| $message .= "\t<li>You can't relate to yourself, it makes you go blind.</li>"; | ||
| } elseif (empty($two)){ | ||
| $message .= "\t<li>No Second Party? Something strange and magical has happened</li>"; | ||
| } elseif ($two == 8){ | ||
| $message .= "\t<li>I'm sorry, but <a href=\"http://www.aquarionics.com/index.php?id=438\">no</a></li>"; | ||
| } else{ | ||
| $q = "select id from relationship where (person_one = $one and " | ||
| ."person_two = $two) or (person_two = $one and person_one = $two) " | ||
| ."and status = 0"; | ||
| $r = mysql_num_rows(safequery($q)); | ||
|
|
||
| if ($r != 0){ | ||
| echo "\t<li>Er, not to cast judgement on your lifestyle, you " | ||
| ."understand, but you are already related to this person " | ||
| ."at least once. This isn't going to stop it going in the " | ||
| ."database, but just to make sure you're aware :-)</li>"; | ||
| } | ||
| } | ||
| return $message; | ||
| } | ||
|
|
||
| function showform($defaults){ | ||
| html_form_start("newrelationship", $_SERVER['PHP_SELF']); | ||
|
|
||
| // Note: It would be a terribly good idea to validate user names | ||
| // before touching this function with a barge pole. | ||
|
|
||
|
|
||
| #$defaults = array(person_one, person_two, rel_onetwo, rel_twoone) | ||
|
|
||
| // Box 'o users | ||
| $users = array(); | ||
| $result = safequery("select id, name from person order by name"); | ||
| while ($row=mysql_fetch_array($result)){ | ||
| $users[$row['id']] = $row['name']; | ||
| } | ||
|
|
||
| // Hidden, Yet labeled. Thus LessHidden :-) | ||
| html_lesshidden("name", "First Party:", $defaults[0], $users[$defaults[0]]); | ||
|
|
||
| echo "<br>"; | ||
|
|
||
| // As much as I hate specific solutions, | ||
| // A bespoke function to display a drop-box of users. | ||
| echo "<LABEL for=\"person_two\"><div class=\"label\">Second Party:</div>"; | ||
| echo " <select name=\"person_two\">\n"; | ||
| foreach ($users as $id => $name){ | ||
| if ($id == $defaults[1]){ | ||
| $selected = " selected"; | ||
| } else { | ||
| $selected = ""; | ||
| } | ||
| echo "\t<option value=\"".$id."\"".$selected.">".$name."</option>\n"; | ||
| } | ||
| echo "</select>\n"; | ||
| echo "</LABEL><br>"; | ||
|
|
||
| html_textbox("rel_onetwo", "Relationship of 1 to 2:", "225", $defaults[2]); | ||
| echo "<br>"; | ||
|
|
||
| html_textbox("rel_twoone", "Relationship of 2 to 1:", "225", $defaults[3]); | ||
| echo "<br>"; | ||
|
|
||
| $buttons = array( | ||
| #array (Label, Name, Button type) | ||
| array ('Resubmit', 'resubmit', 'submit'), | ||
| array ('Reset Form', 'reset', 'reset') | ||
| ); | ||
|
|
||
| html_buttons($buttons); | ||
|
|
||
| echo "<p>ie, "; | ||
| echo $users[$defaults[0]]." is ".$users[$defaults[1]]."'s ".$defaults[2] | ||
| ." and ".$users[$defaults[1]]." is ".$users[$defaults[0]]."'s " | ||
| .$defaults[3]."</p>"; | ||
|
|
||
|
|
||
| html_form_close(); | ||
| } // End Showform | ||
|
|
||
|
|
||
|
|
||
| include("include/library.php"); | ||
| dbconnect(); | ||
| $user = login("Any"); | ||
| include("include/userfuncs.php"); | ||
| build_header("New Relationship"); | ||
|
|
||
| echo "<H1>New Relationship</H1>"; | ||
|
|
||
| if (isset($_GET['action'])){ | ||
| #echo "Action detected"; | ||
| switch ($_GET['action']){ | ||
|
|
||
| case "confirm": | ||
| if (isset($_GET['id'])){ | ||
| #echo "Confirm detected"; | ||
| confirm($_GET['id']); | ||
| } else { | ||
| echo "<h2>Confirm</h2>"; | ||
| echo "<p>No ID Specified. Sod off</p>"; | ||
| } | ||
| break; | ||
| // break | ||
|
|
||
| case "deny": | ||
| if (isset($_GET['id'])){ | ||
| #echo "Confirm detected"; | ||
| deny($_GET['id']); | ||
| } else { | ||
| echo "<h2>Deny</h2>"; | ||
| echo "<p>No ID Specified. Sod off</p>"; | ||
| } | ||
| break; | ||
| // break | ||
|
|
||
| case "delete": | ||
| if (isset($_GET['id'])){ | ||
| echo "<h2>Delete</h2>\n"; | ||
| echo "Delete this relationship? Are you out of your mind?"; | ||
| echo "<br><br>"; | ||
| echo "<a href=\"relate.php?action=reallydelete&id=".$_GET['id'] | ||
| ."\">Delete it! Yes! Do it now!</a> " | ||
| ."| <a href=\"user.php\">Dear Om no, what do you take me for?</a>"; | ||
| } else { | ||
| echo "<h2>Delete</h2>"; | ||
| echo "<p>No ID Specified. Sod off</p>"; | ||
| } | ||
| break; | ||
| // break | ||
|
|
||
| case "reallydelete": | ||
| if (isset($_GET['id'])){ | ||
| #echo "Confirm detected"; | ||
| derelate($_GET['id']); | ||
| } else { | ||
| echo "<h2>Delete</h2>"; | ||
| echo "<p>No ID Specified. Sod off</p>"; | ||
| } | ||
| break; | ||
| // break | ||
|
|
||
| } | ||
| } else { | ||
|
|
||
| $defaults = array($user['id'], $_POST['person_two'], $_POST['rel_onetwo'], $_POST['rel_twoone']); | ||
|
|
||
| echo "<ul>\n"; | ||
|
|
||
| $validate = validate_user($user['id']); | ||
| $validate .= validate_relationship($_POST['person_two'], $user['id']); | ||
| $validate .= validate_exists($_POST['rel_onetwo'], "Relationship part one"); | ||
| $validate .= validate_exists($_POST['rel_twoone'], "Relationship part two"); | ||
|
|
||
| echo $validate."</ul>\n\n"; | ||
|
|
||
| if ($validate == ""){ | ||
| if (isset($_POST['confirm'])){ | ||
| $q = "insert into relationship " | ||
| ."(person_one, person_two, rel_onetwo, rel_twoone, status) values " | ||
| ."(".$defaults[0].", ".$defaults[1].", \"".$defaults[2]."\", \"".$defaults[3]."\", 1)"; | ||
|
|
||
| $subject = $user['name']." has requested a relationship"; | ||
| $msg = $user['name']." has requested a relationship where they are" | ||
| ." your ".$defaults[2]. " and you are their ".$defaults[3] | ||
| .". Please go to your user page and confirm or deny this."; | ||
|
|
||
| sendmessage($defaults[1], 0, $subject, $msg, "mor"); | ||
|
|
||
| logthis($user['name'], "Relationship", $user['name'] . " related to id ". $defaults[1], $q); | ||
|
|
||
| safequery($q); | ||
|
|
||
| html_heading("Confirmed", "2", ""); | ||
|
|
||
| echo "<p>Congratulations, that appears to have gone off without a hitch.</p>"; | ||
|
|
||
| html_heading("What happens now?", "3", ""); | ||
|
|
||
| echo "<p>The relationship is in the Database as \"Unconfirmed\", which " | ||
| ."basically means that I'm waiting for the other side to admit to it." | ||
| //."<br>If they asked me too, I will have sent an email to them " | ||
| //."asking to come to the site and confirm it. Most people have opted" // Commented out until the messaging system is in. | ||
| //." for this." | ||
| ." When they do, they can just click \"Confirm\" on their" | ||
| ." user page, and it'll start being included in the main views. "; | ||
|
|
||
| } else { | ||
| echo "<p>No serious problems found, which is cool. You can now confirm " | ||
| ."the relationship (click Confirm) or you have one last chance to " | ||
| ."fix any spelling errors or anything in the box far below.</p>"; | ||
|
|
||
| html_heading("Confirm:", "3", ""); | ||
| html_form_start("newrelationship", $_SERVER['PHP_SELF']); | ||
| $users = array(); | ||
| $result = safequery("select id, name from person where id = " | ||
| .$defaults[1]." or id = ".$defaults[0]." order by name"); | ||
|
|
||
| while ($row=mysql_fetch_array($result)){ | ||
| $users[$row['id']] = $row['name']; | ||
| } | ||
| echo $users[$defaults[0]]." is ".$users[$defaults[1]]."'s ".$defaults[2] | ||
| ." and ".$users[$defaults[1]]." is ".$users[$defaults[0]]."'s " | ||
| .$defaults[3]."</p>"; | ||
|
|
||
| html_hidden("person_two", $defaults[1]); | ||
| html_hidden("rel_onetwo", $defaults[2]); | ||
| html_hidden("rel_twoone", $defaults[3]); | ||
|
|
||
| $buttons = array( | ||
| #array (Label, Name, Button type) | ||
| array ('Confirm', 'confirm', 'submit') | ||
| ); | ||
|
|
||
| html_buttons($buttons); | ||
|
|
||
| html_form_close(); | ||
|
|
||
| html_heading("Correct:", "3", ""); | ||
| showform($defaults); | ||
| } | ||
| } else { | ||
| html_heading("Please correct:", "3", ""); | ||
| showform($defaults); | ||
| } | ||
|
|
||
| } | ||
| build_footer("New Relationship"); |
| @@ -0,0 +1,46 @@ | ||
| <?PHP | ||
| ////////////////////////////////////////////////////////// | ||
| // Title: Afphrid | ||
| // Project: | ||
| // Description: | ||
| // | ||
| // Authour: Nicholas Avenell | ||
| // Date: | ||
|
|
||
| include("include/library.php"); | ||
| dbconnect(); | ||
| build_header("Statistics"); | ||
| echo "<h1>Statistics</h1>"; | ||
| echo "<i>Anyone using the Afphrid Stats page as a score sheet will find themselves irrevocable members of the group \"Fuckwits\"</i>"; | ||
|
|
||
| function make_top10($query, $title) { | ||
| $result = mysql_query($query); | ||
| print "<h2>$title</h2>\n<ol>\n"; | ||
| while ($row = mysql_fetch_array($result)) { | ||
| $row['name'] = linkName($row['name']); | ||
| print "\t<li>{$row['name']} ({$row['the_count']})</li>"; | ||
| } | ||
| print "</ol>"; | ||
| } | ||
|
|
||
| #Top 10 for Number of Relationships | ||
| $query = "select name, count(*) as the_count "; | ||
| $query .="from person, relationship where "; | ||
| $query .="(person.id = relationship.person_one or person.id = relationship.person_two)"; | ||
| $query .="and status = '2' group by name order by the_count desc limit 10"; | ||
| make_top10($query,"Top 10 for Number of Relationships"); | ||
| /* | ||
| #Top 10 Clubs | ||
| $query = "select clique as name, id, count(*) as the_count "; | ||
| $query .="from cliquelink group by clique order by the_count desc limit 10"; | ||
| make_top10($query,"Top 10 Clubs"); | ||
| #Top 10 Joiners of Clubs | ||
| $query = "select name, id, count(*) as the_count from cliquelink group by "; | ||
| $query .="name order by the_count desc limit 10"; | ||
| make_top10($query,"Top 10 Joiners of Clubs"); | ||
| */ | ||
|
|
||
| build_footer("Statistics"); | ||
| ?> |
| @@ -0,0 +1,68 @@ | ||
| +-------------------+ | ||
| | Tables_in_afphrid | | ||
| +-------------------+ | ||
| | clique | | ||
| | cliquelink | | ||
| | message | | ||
| | person | | ||
| | relationship | | ||
| +-------------------+ | ||
|
|
||
| mysql> describe clique; | ||
| +-------------+--------------+------+-----+---------+----------------+ | ||
| | Field | Type | Null | Key | Default | Extra | | ||
| +-------------+--------------+------+-----+---------+----------------+ | ||
| | id | int(11) | | PRI | NULL | auto_increment | | ||
| | name | varchar(255) | | | | | | ||
| | owner | tinytext | YES | | NULL | | | ||
| | status | int(11) | | | 0 | | | ||
| | description | tinytext | | | | | | ||
| +-------------+--------------+------+-----+---------+----------------+ | ||
|
|
||
| mysql> describe cliquelink; | ||
| +----------+----------+------+-----+---------+----------------+ | ||
| | Field | Type | Null | Key | Default | Extra | | ||
| +----------+----------+------+-----+---------+----------------+ | ||
| | id | int(11) | | PRI | NULL | auto_increment | | ||
| | name | tinytext | | | | | | ||
| | clique | tinytext | | | | | | ||
| | position | tinytext | | | | | | ||
| +----------+----------+------+-----+---------+----------------+ | ||
|
|
||
| mysql> describe message; | ||
| +----------+------------------+------+-----+---------+----------------+ | ||
| | Field | Type | Null | Key | Default | Extra | | ||
| +----------+------------------+------+-----+---------+----------------+ | ||
| | id | int(10) unsigned | | PRI | NULL | auto_increment | | ||
| | msgto | tinytext | YES | | NULL | | | ||
| | msgfrom | tinytext | YES | | NULL | | | ||
| | content | mediumtext | YES | | NULL | | | ||
| | datesent | timestamp(10) | YES | | NULL | | | ||
| | dateread | timestamp(10) | YES | | NULL | | | ||
| | type | tinytext | YES | | NULL | | | ||
| +----------+------------------+------+-----+---------+----------------+ | ||
|
|
||
| mysql> describe person; | ||
| +------------+--------------+------+-----+---------+----------------+ | ||
| | Field | Type | Null | Key | Default | Extra | | ||
| +------------+--------------+------+-----+---------+----------------+ | ||
| | name | varchar(255) | | | | | | ||
| | email | tinytext | YES | | NULL | | | ||
| | homepage | tinytext | YES | | NULL | | | ||
| | password | tinytext | YES | | NULL | | | ||
| | registered | date | YES | | NULL | | | ||
| | prefs | tinytext | YES | | NULL | | | ||
| | id | int(11) | | PRI | NULL | auto_increment | | ||
| +------------+--------------+------+-----+---------+----------------+ | ||
|
|
||
| mysql> describe relationship; | ||
| +------------+----------+------+-----+---------+----------------+ | ||
| | Field | Type | Null | Key | Default | Extra | | ||
| +------------+----------+------+-----+---------+----------------+ | ||
| | id | int(11) | | PRI | NULL | auto_increment | | ||
| | person_one | tinytext | | | | | | ||
| | person_two | tinytext | | | | | | ||
| | rel_onetwo | tinytext | | | | | | ||
| | rel_twoone | tinytext | | | | | | ||
| | status | int(11) | YES | | NULL | | | ||
| +------------+----------+------+-----+---------+----------------+ |