diff --git a/account.php b/account.php index 92015c3ae75b..5ff5200a3470 100644 --- a/account.php +++ b/account.php @@ -97,8 +97,8 @@ function validateUser($user) { if (strlen($user[userid]) > 15) $rval = "the specified username is too long: it must be less than 15 characters."; ### Check to see whether the username or e-mail address are banned: - if ($ban = ban_match($user[userid], $type[usernames])) $rval = "the specified username is banned for the following reason: $ban->reason."; - if ($ban = ban_match($user[email], $type[addresses])) $rval = "the specified e-mail address is banned for the following reason: $ban->reason."; + if ($ban = ban_match($user[userid], $type2index[usernames])) $rval = "the specified username is banned for the following reason: $ban->reason."; + if ($ban = ban_match($user[email], $type2index[addresses])) $rval = "the specified e-mail address is banned for the following reason: $ban->reason."; ### Verify whether username and e-mail address are unique: if (db_num_rows(db_query("SELECT userid FROM users WHERE LOWER(userid)=LOWER('$user[userid]')")) > 0) $rval = "the specified username is already taken."; @@ -114,11 +114,41 @@ function account_makePassword($min_length=6) { return $password; } +function account_track_comments() { + global $user; + + include "function.inc"; + + $output .= "

This page is helpful in case you want to keep track of your most recent comments in any of the discussions. It helps you to review the replies your comments got.\n

\n"; + + ### Perform query: + $sresult = db_query("SELECT s.id, s.subject, COUNT(s.id) as count FROM comments c LEFT JOIN stories s ON c.sid = s.id WHERE c.author = $user->id GROUP BY s.id DESC LIMIT 5"); + + while ($story = db_fetch_object($sresult)) { + $output .= "

  • ". plural($story->count, comment, comments) ." in article `id\">$story->subject`:
  • \n"; + $output .= " \n"; + } + + return $output; +} + switch ($op) { case "Login": session_start(); $user = new User($userid, $passwd); - if ($user && $user->valid()) session_register("user"); + if ($user && $user->valid()) { + session_register("user"); + watchdog(1, "session opened for user `$user->userid'."); + } + else { + watchdog(2, "failed login for user `$userid'."); + } showUser($user->userid); break; case "new": @@ -127,8 +157,14 @@ switch ($op) { case "info": showUser($uname); break; + case "discussion": + include "theme.inc"; + $theme->header(); + $theme->box("Track your comments", account_track_comments()); + $theme->footer(); + break; case "logout": - // session_start(); + watchdog(1, "session closed for user `$user->userid'."); session_unset(); session_destroy(); unset($user); @@ -157,6 +193,8 @@ switch ($op) { $theme->box("Account details", "Your member account has been created and the details necessary to login have been sent to your e-mail account $new[email]. Once you received the account confirmation, hit this link to login."); $theme->footer(); } + + watchdog(1, "new user `$new[userid]' registered with e-mail address `$new[email]'"); } break; case "user": @@ -191,7 +229,7 @@ switch ($op) { ### Display output/content: include "theme.inc"; $theme->header(); - $theme->box("Edit user information", $output); + $theme->box("Edit your information", $output); $theme->footer(); } else { @@ -246,7 +284,7 @@ switch ($op) { ### Display output/content: include "theme.inc"; $theme->header(); - $theme->box("Customize page", $output); + $theme->box("Customize your page", $output); $theme->footer(); } else { diff --git a/admin.inc b/admin.inc index 7480000b2775..e81bd21e1fa2 100644 --- a/admin.inc +++ b/admin.inc @@ -15,11 +15,30 @@ function admin_header() { th { font-family: helvetica, arial; text-align: center; background-color: #C0C0C0; color: #447744; } td { font-family: helvetica, arial; } - + + + + + + +
    +

    +

  • accounts
  • +
  • bans
  • +
  • logs
  • +
  • stories
  • +

    +

  • home
  • +
    +
    + + + \ No newline at end of file diff --git a/admin.php b/admin.php index 1993c14aa4c9..2253c46e520d 100644 --- a/admin.php +++ b/admin.php @@ -1,798 +1,317 @@ -Accounts:\n"; + + while ($account = db_fetch_object($result)) { + $output .= "$account->userid
    "; + } + + print $output; +} + + +/* + * Log administration: + */ +function log_display() { + global $PHP_SELF, $anonymous, $log_level; + + ### Perform query: + $result = db_query("SELECT l.*, u.userid FROM logs l LEFT JOIN users u ON l.user = u.id ORDER BY l.id DESC"); + + $color = array("#FFFFFF", "#FFFFFF", "#90EE90", "#CD5C5C"); + + ### Generate output: + print "

    Logs:

    \n"; + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + + while ($log = db_fetch_object($result)) { + if ($log->userid) print " level] ."\">\n"; + else print " level] ."\">\n"; + } + + print "
    DateUserMessageOperations
    ". date("D d/m, H:m:s", $log->timestamp) ."userid\">$log->userid". substr($log->message, 0, 44) ."id\">more
    ". date("D d/m, H:m:s", $log->timestamp) ."$anonymous". substr($log->message, 0, 44) ."id\">more
    \n"; +} + +function log_view($id) { + ### Perform query: + $result = db_query("SELECT l.*, u.userid FROM logs l LEFT JOIN users u ON l.user = u.id WHERE l.id = $id"); + + if ($log = db_fetch_object($result)) { + print "

    Logs:

    \n"; + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print "
    Level:$log->level
    Date:". date("l, F d, Y - H:i A", $log->timestamp) ."
    User:userid\">". username($log->userid) ."
    Message:$log->message
    Hostname:$log->hostname
    \n"; + } +} + +/* + * Ban administration: + */ + +function ban_check($mask, $category) { + $ban = ban_match($mask, $category); + + print "

    Status:

    \n"; + print "". ($ban ? "Matched ban '$ban->mask' with reason: $ban->reason.

    \n" : "No matching bans for '$mask'.

    \n") .""; +} + +function ban_new($mask, $category, $reason) { + ban_add($mask, $category, $reason, &$message); + + print "

    Status:

    \n"; + print "$message\n"; +} + +function ban_display($category = "") { + global $PHP_SELF, $type2index; + + ### initialize variable: + $category = $category ? $category : 1; + + ### Perform query: + $result = db_query("SELECT * FROM bans WHERE type = $category ORDER BY mask"); + + ### Generate output: + print "

    Bans:

    \n"; + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + + while ($ban = db_fetch_object($result)) { + print " \n"; + } + + print " \n"; + print "
    Active bans\n"; + print "
    \n"; + print " \n"; + print " \n"; + print "
    \n"; + print "
    MaskReasonOperations
    $ban->mask$ban->reasonid\">delete
    %: matches any number of characters, even zero characters.
    _: matches exactly one character.
    \n"; + print "

    \n"; + + print "

    Add new ban:

    \n"; + print "
    \n"; + print "Banmask:
    \n"; + print "

    \n"; + print "Type:
    \n"; + print "

    \n"; + print "Reason:
    \n"; + print "

    \n"; + print "
    \n"; + print "

    \n"; + print "

    \n"; + + print "

    Ban check:

    \n"; + print "
    \n"; + print "Banmask:
    \n"; + print "

    \n"; + print "Type:
    \n"; + print "

    \n"; + print "
    \n"; + print "

    \n"; +} + +/* + * Story administration: + */ + +function story_edit($id) { + global $PHP_SELF, $anonymous, $categories; + + $result = db_query("SELECT stories.*, users.userid FROM stories LEFT JOIN users ON stories.author = users.id WHERE stories.id = $id"); + $story = db_fetch_object($result); + + $output .= "
    \n"; + + $output .= "

    \n"; + $output .= " Author:
    \n"; + if ($story->userid) $output .= " userid\">$story->userid\n"; + else $output .= " $anonymous\n"; + $output .= "

    \n"; + + $output .= "

    \n"; + $output .= " Subject:
    \n"; + $output .= " subject) ."\">
    \n"; + $output .= "

    \n"; + + $output .= "

    Category:
    \n"; + $output .= " \n"; + $output .= "

    \n"; + + $output .= "

    \n"; + $output .= "Abstract:
    \n"; + $output .= "
    \n"; + $output .= "

    \n"; + + $output .= "

    \n"; + $output .= "Editor's note/updates:
    \n"; + $output .= "
    \n"; + $output .= "

    \n"; + + $output .= "

    \n"; + $output .= " Extended story:
    \n"; + $output .= "
    \n"; + $output .= "

    \n"; + + $output .= "

    Status:
    \n"; + $output .= " \n"; + $output .= "

    \n"; + + $output .= "

    \n"; + $output .= " \n"; + $output .= "

    \n"; + $output .= "
    \n"; + + print $output; +} + +function story_save($id, $subject, $abstract, $updates, $article, $category, $status) { + global $PHP_SELF; + + ### Add submission to SQL table: + db_query("UPDATE stories SET subject = '$subject', abstract = '$abstract', updates = '$updates', article = '$article', category = '$category', status = '$status' WHERE id = $id"); + + ### Add log entry: + watchdog(1, "modified story `$subject'."); +} + +function story_display($category = "") { + global $PHP_SELF; + + ### Initialize variables: + $status = array("deleted", "pending", "public"); + + ### Perform SQL query: + $result = db_query("SELECT * FROM stories"); + + ### Display stories: + $output .= "

    Stories:

    \n"; + $output .= "\n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + + while ($story = db_fetch_object($result)) { + $output .= " \n"; + } + + $output .= "
    SubjectStatusOperations
    id\">$story->subject". $status[$story->status] ."id\">edit
    \n"; + + print $output; +} + include "functions.inc"; -include "authentication.inc"; +include "function.inc"; +include "admin.inc"; -function login() { - include "theme.inc"; - $theme->header(); - $theme->box("Login", "

    Name:

    Password:

    "); - $theme->footer(); -} +admin_header(); -function logout() { - setcookie("admin"); - - include "theme.inc"; - $theme->header(); - ?> -



    -

    You are now logged out!

    -

    You have been logged out of the system. Since authentication details are stored by using cookies, logging out is only necessary to prevent those who have access to your computer from abusing your account.

    - footer(); -} - -function backup() { - include "config.inc"; - if ($system == 0) { - exec("mysqldump -h $dbhost -u $dbuname -p$dbpass $dbname | mail -s \"[$sitename] MySQL backup\" $notify_email"); - exec("mysqldump -h $dbhost -u $dbuname -p$dbpass $dbname > ../$sitename-backup-". date("Ymd", time()).".mysql"); - } - else print "

    Warning: the backup feature is only supported on UNIX systems. Check your configuration file if you are using a UNIX system.

    "; -} - -function main() { - include "config.inc"; - include "theme.inc"; - $theme->header(); - dbconnect(); - - $result = mysql_query("SELECT qid, subject, timestamp FROM queue order by timestamp"); - - echo "
    "; - echo ""; - - if (mysql_num_rows($result) != 0) { - while (list($qid, $subject, $timestamp) = mysql_fetch_row($result)) { - - ### format date: - $datetime = date("F d - h:i:s A", $timestamp); - - ### generate overview: - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; - $dummy++; +switch ($section) { + case "accounts": + switch ($op) { + default: + account_display(); } - } - - if ($dummy < 1) { - echo " "; - } - else { - echo " "; - } - - echo " "; - echo " "; - echo "
    $subject$datetime
    There are currently no new submissions available.
    Article ID:
    Write and post an article as administrator.
    "; - - mysql_free_result($result); - ?> -
    -
  • Edit global blocks on main page.

  • - Allows you to update the content blocks on the main page. -
    -
  • Edit user accounts.

  • - Add, delete, block, view and update user accounts. -
    -
  • Edit adminstrators accounts.

  • -
    -
  • Backup MySQL tables.

  • - Will mail a backup of the MySQL database to ''. -
    -
  • Webboard manager.

  • - Allows you to delete flamebait post or threads from the webboard. -
    -
  • Poll manager.

  • - Install, delete or update polls. -
    -
  • Referring site manager.

  • - Edit, block or delete sites that participate with the referring site program. -
    -
  • Resource manager. (not implemented yet)

  • - Allows admins to maintain a list of resources, news sites and other interesting start points to start their search for news. -
    -
  • Logout
  • - footer(); -} - -/*********************************************************/ -/* block functions */ -/*********************************************************/ - -function block_overview() { - include "theme.inc"; - $theme->header(); - - dbconnect(); - $result = mysql_query("SELECT id, title, content FROM blocks"); - - if (mysql_num_rows($result) > 0) { - while(list($id, $title, $content) = mysql_fetch_array($result)) { - echo "
    "; - echo " Title:
    "; - echo " "; - echo "

    "; - - echo " Content:
    "; - echo " "; - echo "

    "; - - echo " "; - echo " "; - echo "
    "; + break; + case "bans": + include "ban.inc"; + switch ($op) { + case "Add ban": + ban_new($mask, $category, $reason); + ban_display($category); + break; + case "Check ban": + ban_check($mask, $category); + ban_display($category); + break; + case "delete": + ban_delete($id); + ban_display($category); + break; + default: + ban_display($category); } - } - ?> -
    -
    - Title:
    - -

    - - Content:
    - -

    - -
    - - footer(); + break; + case "logs": + switch ($op) { + case "view": + log_view($id); + break; + default: + log_display($category); + } + break; + case "stories": + switch ($op) { + case "edit": + story_edit($id); + break; + case "Save story": + story_save($id, $subject, $abstract, $updates, $article, $category, $status); + story_edit($id); + break; + default: + story_display($category); + } + break; + default: + print "Bad visitor! Bad, bad visitor! What are you looking for? Maybe it's here?"; } -function block_add($title, $content) { - dbconnect(); - mysql_query("INSERT INTO blocks VALUES (NULL,'$aid','$title','$content')"); - header("Location: admin.php?op=main"); -} +admin_footer(); -function block_update($id, $title, $content) { - dbconnect(); - mysql_query("update blocks set title='$title', content='$content' where id=$id"); - header("Location: admin.php?op=main"); -} - -function block_delete($id) { - dbconnect(); - mysql_query("DELETE FROM blocks WHERE id = '$id'"); - header("Location: admin.php?op=main"); -} - - -/*********************************************************/ -/* user account functions */ -/*********************************************************/ - -function user_overview() { - include "theme.inc"; - $theme->header(); - dbconnect(); - $result = mysql_query("SELECT * FROM users"); - while ($account = mysql_fetch_object($result)) { - $count++; - print "$count. $account->uname [ uname\">view | edit | block | delete ]
    "; - } - $theme->footer(); -} - -/*********************************************************/ -/* article functions */ -/*********************************************************/ -function news_queue_delete($qid) { - dbconnect(); - $result = mysql_query("DELETE FROM queue WHERE qid = $qid"); - header("Location: admin.php?op=main"); -} - - -function news_display($qid) { - global $user, $subject, $article; - - include "config.inc"; - include "header.inc"; - - dbconnect(); - - if (isset($qid)) $result = mysql_query("SELECT qid, uid, uname, timestamp, subject, abstract, article, category FROM queue WHERE qid = $qid"); - else $result = mysql_query("SELECT qid, uid, uname, timestamp, subject, abstract, article, category FROM queue LIMIT 1"); - - list($qid, $uid, $uname, $timestamp, $subject, $abstract, $article, $category) = mysql_fetch_row($result); - mysql_free_result($result); - - $subject = stripslashes($subject); - $abstract = stripslashes($abstract); - $article = stripslashes($article); - - $theme->preview("", $uname, $timestamp, $subject, "", $abstract, "", $article); - ?> - -
    - -

    - Author or poster:
    - "> -

    - -

    - Subject:
    - "> -

    - -

    - Department:
    - dept.
    - - - Example departments: -

    - - -

    - -

    - Category:
    - -

    - -

    - Author's abstract:
    -
    - Will be displayed on the main page! -

    - -

    - Editor's comments:
    -
    - Will be displayed on the main page after the abstract. -

    - -

    - Extended article:
    -
    - Will be displayed on the article's page when following the 'read more'-link. -

    - - "> - "> - - - -
    - - footer(); -} - -function news_preview($qid, $uid, $author, $subject, $department, $category, $abstract, $comments, $article) { - global $user, $boxstuff, $aid; - include "config.inc"; - include "theme.inc"; - - $theme->header(); - - $subject = stripslashes($subject); - $agstract = stripslashes($abstract); - $comments = stripslashes($comments); - $article = stripslashes($article); - - $theme->preview($aid, $author, time(), $subject, $department, $abstract, $comments, $article); - $theme->footer(); - ?> - - -
    - -

    - Author or poster:
    - "> -

    - -

    - Subject:
    - "> -

    - -

    - Department:
    - "> dept.
    - - Example departments: -

    - -

    - -

    - Category:
    - -

    - -

    - Author's abstract:
    -
    - Will be displayed on the main page! -

    - -

    - Editor's comments:
    -
    - Will be displayed on the main page after the abstract. -

    - -

    - Extended article:
    -
    - Will be displayed on the article's page when following the 'read more'-link. -

    - - "> - "> - - - -
    - - footer(); -} - -function news_post($qid, $uid, $author, $subject, $department, $category, $abstract, $comments, $article) { - global $aid; - dbconnect(); - - if ($uid == -1) $author = ""; - - $subject = stripslashes(FixQuotes($subject)); - $abstract = stripslashes(FixQuotes($abstract)); - $comments = stripslashes(FixQuotes($comments)); - $article = stripslashes(FixQuotes($article)); - - $result = mysql_query("INSERT INTO stories (sid, aid, subject, time, abstract, comments, article, category, informant, department) VALUES (NULL, '$aid', '$subject', '". time() ."', '$abstract', '$comments', '$article', '$category', '$author', '$department')"); - - ### remove article from queue: - news_queue_delete($qid); -} - -function news_edit($sid) { - global $user, $subject, $abstract, $comments, $article; - - include "theme.inc"; - include "config.inc"; - - $theme->header(); - - dbconnect(); - - $result = mysql_query("SELECT * FROM stories where sid = $sid"); - $article = mysql_fetch_object($result); - mysql_free_result($result); - - $theme->preview($article->author, $article->informant, $article->time, $article->subject, $article->department, $article->abstract, $article->comments, $article->article); - - ?> - -
    - -

    - Author or poster:
    - aid"; ?>"> -

    - -

    - Subject:
    - subject"; ?>"> -

    - -

    - Department:
    - department"; ?>"> dept.
    - - Example departments: -

    - -

    - -

    - Category:
    - -

    - -

    - Author's abstract:
    -
    - Will be displayed on the main page! -

    - -

    - Editor's comments:
    -
    - Will be displayed on the main page after the abstract. -

    - -

    - Extended article:
    -
    - Will be displayed on the article's page when following the 'read more'-link. -

    - - - "> -
    - - footer(); -} - -function news_update($sid, $subject, $category, $department, $abstract, $comments, $article) { - global $aid; - dbconnect(); - $subject = stripslashes(FixQuotes($subject)); - $department = stripslashes(FixQuotes($department)); - $abstract = stripslashes(FixQuotes($abstract)); - $comments = stripslashes(FixQuotes($comments)); - $article = stripslashes(FixQuotes($article)); - mysql_query("UPDATE stories SET subject = '$subject', category = '$category', department = '$department', abstract = '$abstract', comments = '$comments', article = '$article' WHERE sid = $sid"); - header("Location: admin.php?op=main"); -} - -function news_admin_write() { - include "theme.inc"; - include "config.inc"; - dbconnect(); - - $theme->header(); - ?> - -
    - -

    - Subject:
    - -

    - -

    - Department:
    - dept.
    - - - Example departments: -

    - - -

    - -

    - Category:
    - -

    - -

    - Introduction of article:
    -
    - Will be displayed on the main page. -

    - -

    - Rest of article:
    -
    - Will be displayed on the article's page when following the 'read more'-link. -

    - - - -
    - footer(); -} - -function news_admin_preview($subject, $category, $department, $abstract, $article) { - global $aid; - include "theme.inc"; - include "config.inc"; - $subject = stripslashes($subject); - $intro = stripslashes($intro); - $rest = stripslashes($rest); - - $theme->header(); - $theme->preview("", $aid, $time, $subject, "", $abstract, "", $article); - ?> - -
    - -

    - Subject:
    - "> -

    - -

    - Department:
    - "> dept.
    - - - Example departments: -

    - - -

    - -

    - Category:
    - -

    - -

    - Introduction of article:
    -
    - Will be displayed on the main page. -

    - -

    - Rest of article:
    -
    - Will be displayed on the article's page when following the 'read more'-link. -

    - - - -
    - - footer(); -} - -function news_admin_post($subject, $category, $department, $abstract, $article, $category) { - global $aid; - dbconnect(); - - $subject = stripslashes(FixQuotes($subject)); - $intro = stripslashes(FixQuotes($intro)); - $rest = stripslashes(FixQuotes($rest)); - - $result = mysql_query("INSERT INTO stories VALUES (NULL, '$aid', '$subject', '". time() ."', '$abstract', '', '$article', '$category', '$aid', '$department')"); - if (!$result) { - echo mysql_errno(). ": ".mysql_error(). "
    "; - exit(); - } - header("Location: admin.php?op=main"); -} - -/*********************************************************/ -/* admin admining */ -/*********************************************************/ - -function displayadmins() { - $titlebar = "current authors"; - include "header.inc"; - dbconnect(); - $result = mysql_query("select aid from authors"); - echo ""; - while(list($a_aid) = mysql_fetch_row($result)) { - echo ""; - echo ""; - echo ""; - } - echo "
    $a_aidModify InfoDelete Author
    "; - echo "
    "; - echo "Handle:
    "; - echo "Name:
    "; - echo "Email:
    "; - echo "URL:
    "; - echo "Password:
    "; - echo "
    "; - include "footer.inc"; -} - -function modifyadmin($chng_aid) { - $titlebar = "update $chng_aid"; - include "header.inc"; - dbconnect(); - $result = mysql_query("select aid, name, url, email, pwd from authors where aid='$chng_aid'"); - list($chng_aid, $chng_name, $chng_url, $chng_email, $chng_pwd) = mysql_fetch_row($result); - echo "
    "; - echo "Name: $chng_name
    "; - echo "Handle:
    "; - echo "Email:
    "; - echo "URL:
    "; - echo "Password:
    "; - echo "Retype Password: (for changes only)
    "; - echo "
    "; - include "footer.inc"; -} - -function updateadmin($chng_aid, $chng_name, $chng_email, $chng_url, $chng_pwd, $chng_pwd2) { - if ($chng_pwd2 != "") { - if($chng_pwd != $chng_pwd2) { - $titlebar = "bad pass"; - include "header.inc"; - echo "Sorry, the new passwords do not match. Click back and try again"; - include "footer.inc"; - exit; - } - dbconnect(); - $result = mysql_query("update authors set aid='$chng_aid', email='$chng_email', url='$chng_url', pwd='$chng_pwd' where NAME='$chng_name'"); - header("Location: admin.php?op=main"); - } else { - dbconnect(); - $result = mysql_query("update authors set aid='$chng_aid', email='$chng_email', url='$chng_url' where NAME='$chng_name'"); - header("Location: admin.php?op=main"); - } -} - - -if ($admin) { - switch($op) { - case "main": - main(); - break; - case "blocks": - block_overview(); - break; - case "Add new block": - block_add($title, $content); - break; - case "Delete block": - block_delete($id); - break; - case "Update block": - block_update($id, $title, $content); - break; - case "submission": - // fall through - case "View article": - news_display($qid); - break; - case "Preview article": - news_preview($qid, $uid, $author, $subject, $department, $category, $abstract, $comments, $article); - break; - case "Post article": - news_post($qid, $uid, $author, $subject, $department, $category, $abstract, $comments, $article); - break; - case "Edit article": - news_edit($sid); - break; - case "Update article": - news_update($sid, $subject, $category, $department, $abstract, $comments, $article); - break; - case "Delete article": - news_queue_delete($qid); - break; - case "news_admin_write": - news_admin_write($sid); - break; - case "Preview admin article": - news_admin_preview($subject, $category, $department, $abstract, $article); - break; - case "Post admin article": - news_admin_post($subject, $category, $department, $abstract, $article); - break; - case "mod_authors": - displayadmins(); - break; - case "modifyadmin": - modifyadmin($chng_aid); - break; - case "Update author": - updateadmin($chng_aid, $chng_name, $chng_email, $chng_url, $chng_pwd, $chng_pwd2); - break; - case "Add author": - dbconnect(); - $result = mysql_query("INSERT INTO authors VALUES ('$add_aid','$add_name','$add_url','$add_email','$add_pwd')"); - if (!$result) { - echo mysql_errno(). ": ".mysql_error(). "
    "; return; - } - header("Location: $that_url/admin.php?op=main"); - break; - case "deladmin": - include "header.inc"; - echo "Are you sure you want to delete $del_aid?
    "; - echo "Yes     No"; - include "footer.inc"; - break; - case "deladminconf": - dbconnect(); - mysql_query("delete from authors where aid='$del_aid'"); - header("Location: $that_url/admin.php?op=main"); - break; - case "create": - poll_createPoll(); - break; - case "createPosted": - poll_createPosted(); - break; - case "remove": - poll_removePoll(); - break; - case "removePosted": - poll_removePosted(); - break; - case "user_overview": - user_overview(); - break; - case "backup": - backup(); - main(); - break; - case "view": - poll_viewPoll(); - break; - case "viewPosted": - poll_viewPosted(); - break; - case "logout": - logout(); - break; - default: - main(); - break; - } -} else { - login(); -} ?> \ No newline at end of file diff --git a/authentication.inc b/authentication.inc deleted file mode 100644 index 16a91c4a0349..000000000000 --- a/authentication.inc +++ /dev/null @@ -1,20 +0,0 @@ - \ No newline at end of file diff --git a/ban.inc b/ban.inc index 72f6f2ce0e80..1d9fa095ed72 100644 --- a/ban.inc +++ b/ban.inc @@ -1,9 +1,13 @@ 0x01, - "profanity" => 0x02, - "hostnames" => 0x03, - "usernames" => 0x04); +$type2index = array("addresses" => 0x01, + "profanity" => 0x02, + "hostnames" => 0x03, + "usernames" => 0x04); +$index2type = array(0x01 => "addresses", + 0x02 => "profanity", + 0x03 => "hostnames", + 0x04 => "usernames"); function ban_match($mask, $category) { ### Perform query: @@ -14,6 +18,8 @@ function ban_match($mask, $category) { } function ban_add($mask, $category, $reason, $message = "") { + global $index2type; + if (empty($mask)) { $message = "Failed: empty banmasks are not allowed.

    \n"; } @@ -23,12 +29,24 @@ function ban_add($mask, $category, $reason, $message = "") { else { $result = db_query("INSERT INTO bans (mask, type, reason, timestamp) VALUES ('$mask', '$category', '$reason', '". time() ."')"); $message = "Added new ban with mask `$mask'.

    \n"; + + ### Add log entry: + watchdog(1, "added new ban `$mask' to category `". $index2type[$category] ."' with reason `$reason'."); } } function ban_delete($id) { - ### Perform query: - $result = db_query("DELETE FROM bans WHERE id = $id"); + global $index2type; + + $result = db_query("SELECT * FROM bans WHERE id = $id"); + + if ($ban = db_fetch_object($result)) { + ### Perform query: + $result = db_query("DELETE FROM bans WHERE id = $id"); + + ### Deleted log entry: + watchdog(1, "removed ban `$ban->mask' from category `". $index2type[$ban->type] ."'."); + } } ?> diff --git a/config.inc b/config.inc index c923769f3f50..d51bef6bbc61 100644 --- a/config.inc +++ b/config.inc @@ -3,9 +3,15 @@ # # MySQL settings: # -$dbhost = "zind.net"; + +#$dbhost = "zind.net"; +#$dbuname = "dries"; +#$dbpass = "Abc123"; +#$dbname = "dries"; + +$dbhost = ""; $dbuname = "dries"; -$dbpass = "Abc123"; +$dbpass = "oakley"; $dbname = "dries"; # @@ -64,7 +70,7 @@ $anonymous = "Anonymous Chicken"; # # Default theme: # -$cfg_theme = "Dries"; +$cfg_theme = "UnConeD"; # # Submission moderation votes: diff --git a/discussion.php b/discussion.php index 4de067b46f07..90929ed848b9 100644 --- a/discussion.php +++ b/discussion.php @@ -14,7 +14,7 @@ function comments_kids ($cid, $mode, $order = 0, $thold = 0, $level = 0, $dummy $comments++; $link = "sid&pid=$comment->cid&mode=$mode&order=$order&thold=$thold\">hlcolor2\">reply to this comment"; - $theme->comment($comment->userid, $comment->subject, $comment->comment, $comment->timestamp, $comment->url, $comment->femail, $comment->score, $comment->cid, $link); + $theme->comment($comment->userid, stripslashes($comment->subject), stripslashes($comment->comment), $comment->timestamp, stripslashes($comment->url), stripslashes($comment->femail), $comment->score, $comment->cid, $link); comments_kids($comment->cid, $mode, $order, $thold, $level + 1, $dummy + 1); } @@ -133,7 +133,7 @@ function comments_reply($pid, $sid, $mode, $order, $thold) { ### Extract parent-information/data: if ($pid) { $item = db_fetch_object(db_query("SELECT comments.*, users.userid FROM comments LEFT JOIN users ON comments.author = users.id WHERE comments.cid = $pid")); - $theme->comment($item->userid, $item->subject, $item->comment, $item->timestamp, $item->url, $item->femail, $item->score, $item->cid, "reply to this comment"); + $theme->comment($item->userid, stripslashes($item->subject), stripslashes($item->comment), $item->timestamp, stripslashes($item->url), stripslashes($item->femail), $item->score, $item->cid, "reply to this comment"); } else { $item = db_fetch_object(db_query("SELECT stories.*, users.userid FROM stories LEFT JOIN users ON stories.author = users.id WHERE stories.status != 0 AND stories.id = $sid")); @@ -162,13 +162,13 @@ function comments_reply($pid, $sid, $mode, $order, $thold) { $output .= " Subject:
    \n"; if (!eregi("Re:",$item->subject)) $item->subject = "Re: $item->subject"; // Only one 'Re:' will just do fine. ;) - $output .= " subject\">\n"; + $output .= " subject) ."\">\n"; $output .= "

    \n"; ### Comment field: $output .= "

    \n"; $output .= " Comment:
    \n"; - $output .= "
    \n"; + $output .= "
    \n"; $output .= "

    \n"; ### Hidden fields: @@ -189,8 +189,8 @@ function comment_preview($pid, $sid, $subject, $comment, $mode, $order, $thold) global $anonymous, $user, $theme; ### Preview comment: - if ($user) $theme->comment("", $subject, $comment, time(), "", "", "na", "", "reply to this comment"); - else $theme->comment($user->userid, $subject, $comment, time(), $user->url, $user->femail, "na", "", "reply to this comment"); + if ($user) $theme->comment("", stripslashes($subject), stripslashes($comment), time(), "", "", "na", "", "reply to this comment"); + else $theme->comment($user->userid, stripslashes($subject), stripslashes($comment), time(), stripslashes($user->url), stripslashes($user->femail), "na", "", "reply to this comment"); ### Build reply form: $output .= "
    \n"; @@ -212,13 +212,13 @@ function comment_preview($pid, $sid, $subject, $comment, $mode, $order, $thold) ### Subject field: $output .= "

    \n"; $output .= " Subject:
    \n"; - $output .= " \n"; + $output .= " \n"; $output .= "

    \n"; ### Comment field: $output .= "

    \n"; $output .= " Comment:
    \n"; - $output .= "
    \n"; + $output .= "
    \n"; $output .= "

    \n"; ### Hidden fields: diff --git a/error.php b/error.php index 68aa86b24a0b..85d1aac92db6 100644 --- a/error.php +++ b/error.php @@ -12,7 +12,7 @@ Temporary debug output:
    * STATUS...:
    * URL......:
    - * METHDOD..:
    + * METHOD...:
    Processed output:
    diff --git a/faq.php b/faq.php index e7387f61d910..2910da2cc644 100644 --- a/faq.php +++ b/faq.php @@ -10,7 +10,7 @@ $output = " The Online Jargon Files written by Eric Raymond define a FAQ as:

    FAQ /F-A-Q/ or /fak/ n.
    [Usenet] 1. A Frequently Asked Question. 2. A compendium of accumulated lore, posted periodically to high-volume newsgroups in an attempt to forestall such questions. Some people prefer the term FAQ list or FAQL /fa'kl/, reserving FAQ' for sense 1.

    RTFAQ /R-T-F-A-Q/ imp.
    [Usenet: primarily written, by analogy with RTFM] Abbreviation for \"Read The FAQ!\", an exhortation that the person addressed ought to read the newsgroup's FAQ list before posting questions.

    -

    RTFM /R-T-F-M/ imp.
    [Unix] Abbreviation for \"Read The Fucking Manual\". 1. Used by gurus to brush off questions they consider trivial or annoying. 2. Used when reporting a problem to indicate that you aren't just asking out of randomness. \"No, I can't figure out how to interface Unix to my toaster, and yes, I have RTFM.\" Unlike sense 1, this use is considered polite.

    +

    RTFM /R-T-F-M/ imp.
    [Unix] Abbreviation for \"Read The Fucking Manual\". 1. Used by gurus to brush off questions they consider trivial or annoying. 2. Used when reporting a problem to indicate that you aren't just asking out of randomness. \"No, I can't figure out how to interface Unix to my toaster, and yes, I have RTFM.\" Unlike sense 1, this use is considered polite.

    User n.
    1. Someone doing `real work' with the computer, using it as a means rather than an end. Someone who pays to use a computer. 2. A programmer who will believe anything you tell him. One who asks silly questions. [GLS observes: This is slightly unfair. It is true that users ask questions (of necessity). Sometimes they are thoughtful or deep. Very often they are annoying or downright stupid, apparently because the user failed to think for two seconds or look in the documentation before bothering the maintainer.] 3. Someone who uses a program from the outside, however skillfully, without getting into the internals of the program. One who reports bugs instead of just going ahead and fixing them.

    @@ -19,8 +19,11 @@ $output = "
    Why moderatiom, trust metrics and collaborative filtering?
    To help individuals and communities address the challenges of information overload.

    As each new piece of information competes for attention, people quickly tend to become overwhelmed and seek assistance in identifying the most interesting, worthwhile, valuable or enteraining items. Not to mention the fact, reader-contributed content and other levels of interactivity tend to become chaotic, bloated and disreputable.

    Therefore, we decided to develop a public system powered by a community that aims to bring quality content to everyone's attention and to filter out all junk: to sort the wheat from the chaff. The output should be something clean and homogenized featuring quality content, and should slide down the gullet far more easily. Another objective is to provide a customized service according to public and individual preferences, whether expressed or inferred.

    Yes, you are right. It all sounds a bit idealistic, not to mention hypothetical. However, don't get this wrong: this isn't a new concept, various such systems exist nowadays (like slashdot.org or kuro5hin.org). We just happen to want our own system.

    Last but not least we, the $sitename team, don't want the responsibility to manually review each post and to select the ones worthy. Systematic editing by individual editors is nice and dandy, if you get paid for it or if you have some time to kill. Afterall, we are not writers, critics nor reviewers for that matter; we are programmers, designers and technicians.

    - -
    How does submission moderation work?
    + +
    Isn't moderation elitist?
    +
    To some extent, yes. The system is not designed to allow totally open and unfiltered access. It is intended to create a good place for people who are interested in a topic to come together and communicate. You can't communicate over a noisy channel, so part of our job is to reduce the ability for malicious users to create noise.

    + +
    How does submission moderation work?
    under construction

    How does comment moderation work?
    diff --git a/function.inc b/function.inc new file mode 100644 index 000000000000..9bc0f46052e1 --- /dev/null +++ b/function.inc @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/functions.inc b/functions.inc index 83476c9a2731..340191345c95 100644 --- a/functions.inc +++ b/functions.inc @@ -1,27 +1,28 @@ $value) { if ($key == "passwd") { $query .= "$key=PASSWORD('". addslashes($value) ."'), "; } else { $query .= "$key='". addslashes($value) ."', "; } } $query = substr($query, 0, -2); - dbconnect(); - if (!empty($id)) { mysql_query("UPDATE $dbase SET $query WHERE id=$id") or die(mysql_error()); return $id; } - else { mysql_query("INSERT INTO $dbase SET $query") or die(mysql_error()); return mysql_insert_id(); } -} - -function dbconnect() { - include "config.inc"; - mysql_pconnect($dbhost, $dbuname, $dbpass) or die(mysql_Error()); - mysql_select_db("$dbname") or die ("Unable to select database"); + + if (!empty($id)) { db_query("UPDATE $dbase SET $query WHERE id=$id") or die(mysql_error()); return $id; } + else { db_query("INSERT INTO $dbase SET $query") or die(mysql_error()); return mysql_insert_id(); } } function morelink_bytes($theme, $story) { @@ -96,12 +97,6 @@ function addRefer($url) { } } -function id2story($id) { - ### Perform query: - $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.id = $id"); - return db_fetch_object($result); -} - function displayModerationResults($theme, $story) { global $user; @@ -121,7 +116,7 @@ function displayModerationResults($theme, $story) { function displayRelatedLinks($theme, $story) { ### Parse story for -tags: - $text = "$story->abstract $story->updates $story->article"; + $text = stripslashes("$story->abstract $story->updates $story->article"); while ($text = stristr($text, "") + 4); $text = stristr($text, ""); @@ -195,7 +190,7 @@ function displayUserblock($theme) { global $user; if ($user && $user->ublockon) { - $content .= "

    [ hlcolor2\">edit | hlcolor2\">logout ]

    "; + $content .= "

    [ hlcolor2\">edit | hlcolor2\">Track comments | hlcolor2\">logout]

    "; $theme->box("$user->userid's box", $user->content); } } @@ -224,32 +219,28 @@ function displayCalendar($theme, $date) { $theme->box("Browse archives", $calendar->display()); } -function displayAccountSettings($theme) { +function displayAccount($theme) { global $user; if ($user && $user->userid) { + + function submission_number() { + $result = db_query("SELECT COUNT(id) FROM stories WHERE status = 1"); + return ($result) ? mysql_result($result, 0) : 0; + } + ### Display account settings: - $content = "
  • User info
  • "; - $content .= "
  • Edit user info
  • "; - $content .= "
  • Customize page
  • "; - $content .= "
  • Logout
  • "; + $content = "
  • view your information
  • "; + $content .= "
  • edit your information
  • "; + $content .= "
  • customize your page
  • "; + $content .= "
  • track your comments
  • "; + $content .= "
  • moderate submissions (". submission_number() .")
  • "; + $content .= "
  • logout
  • "; $theme->box("$user->userid's account", "$content"); } } -function displayAccount($theme) { - global $user; - - include "submission.inc"; - - if ($user && $user->userid) { - ### Display account settings: - $content .= "
  • moderate submissions (". submission_count() .")
  • "; - $theme->box("$user->userid's account", "$content"); - } -} - function displayReferrals($theme, $number = 10) { $count = 1; diff --git a/poll.php b/poll.php index e1e530b5e6cc..8ff5312a55dd 100644 --- a/poll.php +++ b/poll.php @@ -39,13 +39,11 @@ function deletePoll($id) { - dbconnect(); $query = "DELETE FROM poll WHERE id = $id"; $result = mysql_query($query); } function enablePoll($id) { - dbconnect(); $query = "UPDATE poll SET status = 0 WHERE status = 1"; $result = mysql_query($query); @@ -54,13 +52,11 @@ function enablePoll($id) { } function disablePoll($id) { - dbconnect(); $query = "UPDATE poll SET status = 0 WHERE id = $id"; $result = mysql_query($query); } function castVote($vote) { - dbconnect(); $query = "SELECT * FROM poll WHERE status = 1"; $result = mysql_query($query); if ($poll = mysql_fetch_object($result)) { @@ -72,34 +68,28 @@ function castVote($vote) { } function addPoll($question, $answer1, $answer2, $answer3 = "", $answer4 = "", $answer5 = "", $answer6 = "") { - dbconnect(); $query = "INSERT INTO poll (question, answer1, answer2, answer3, answer4, answer5, answer6) VALUES ('$question', '$answer1', '$answer2', '$answer3', '$answer4', '$answer5', '$answer6')"; $result = mysql_query($query); } function updatePoll($id, $question, $answer1, $answer2, $answer3 = "", $answer4 = "", $answer5 = "", $answer6 = "") { - dbconnect(); $query = "UPDATE poll SET question = '$question', answer1 = '$answer1', answer2 = '$answer2', answer3 = '$answer3', answer4 = '$answer4', answer5 = '$answer5', answer6 = '$answer6' WHERE id = $id"; $result = mysql_query($query); } function getPoll($id) { - dbconnect(); $query = "SELECT * FROM poll WHERE id = $id"; $result = mysql_query($query); if ($poll = mysql_fetch_object($result)) return $poll; } function getActivePoll() { - dbconnect(); $query = "SELECT * FROM poll WHERE status = 1"; $result = mysql_query($query); if ($poll = mysql_fetch_object($result)) return $poll->id; } function getPollArray() { - dbconnect(); - $query = "SELECT * FROM poll"; $result = mysql_query($query); @@ -203,7 +193,6 @@ if (!$box) { } if ($section == "poll") { - include "authentication.inc"; if ($method == "add") { if ($admin) { addPoll($question, $answer1, $answer2, $answer3, $answer4, $answer5, $answer6); diff --git a/refer.php b/refer.php index 9cee9e77d7c0..861a7660b96f 100644 --- a/refer.php +++ b/refer.php @@ -9,8 +9,6 @@ include "theme.inc"; $theme->header(); -dbconnect(); - /* function addRefer($url) { $query = "SELECT * FROM refer WHERE url = '$url'"; diff --git a/submission.inc b/submission.inc index 34e45844b019..c1adcc9d84f5 100644 --- a/submission.inc +++ b/submission.inc @@ -20,7 +20,7 @@ function submission_vote($id, $vote, $comment) { db_query("UPDATE stories SET score = score $vote, votes = votes + 1 WHERE id = $id"); ### Update the comments (if required): - if ($comment) db_query("INSERT INTO comments (sid, subject, comment, hostname, timestamp) VALUES($id, '". addslashes(substr($comment, 0, 29)) ." ...', '". addslashes($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."')"); + if ($comment) db_query("INSERT INTO comments (sid, author, subject, comment, hostname, timestamp) VALUES($id, $user->id, '". addslashes(substr($comment, 0, 29)) ." ...', '". addslashes($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."')"); ### Update user's history record: $user->setHistory("s$id", "$vote"); // s = submission diff --git a/submit.php b/submit.php index a38f7dd249ad..e97c25537c32 100644 --- a/submit.php +++ b/submit.php @@ -40,7 +40,7 @@ function submit_enter() { $output .= "

    \n"; $output .= " Extended story:
    \n"; - $output .= "
    \n"; + $output .= "
    \n"; $output .= " HTML is nice and dandy, but double check those URLs and HTML tags!\n"; $output .= "

    \n"; @@ -55,7 +55,7 @@ function submit_enter() { $theme->footer(); } -function submit_preview($subject, $abstract, $story, $category) { +function submit_preview($subject, $abstract, $article, $category) { global $anonymous, $categories, $theme, $user; $output .= "\n"; @@ -90,7 +90,7 @@ function submit_preview($subject, $abstract, $story, $category) { $output .= "

    \n"; $output .= " Extended story:
    \n"; - $output .= "
    \n"; + $output .= "
    \n"; $output .= " HTML is nice and dandy, but double check those URLs and HTML tags!\n"; $output .= "

    \n"; @@ -119,7 +119,7 @@ function submit_preview($subject, $abstract, $story, $category) { $output .= "
    \n"; $theme->header(); - $theme->preview($user->userid, stripslashes($subject), stripslashes($abstract), "", stripslashes($story), date("l, F d, Y - H:i A", time()), stripslashes($category), "we-hate-typoes"); + $theme->preview($user->userid, stripslashes($subject), stripslashes($abstract), "", stripslashes($article), date("l, F d, Y - H:i A", time()), stripslashes($category), "we-hate-typoes"); $theme->box("Submit a story", $output); $theme->footer(); } @@ -140,6 +140,9 @@ function submit_submit($subject, $abstract, $article, $category) { $message = "New submission:\n\nsubject...: $subject\nauthor....: $user->userid <$user->email>\ncategory..: $category\nabstract..:\n$abstract\n\narticle...:\n$article"; mail($notify_email, "$notify_subject $subject", $message, "From: $notify_from\nX-Mailer: PHP/" . phpversion()); } + + ### Add log entry: + watchdog(1, "added new submission with subject `$subject'."); } include "functions.inc"; @@ -147,10 +150,10 @@ include "theme.inc"; switch($op) { case "Preview submission": - submit_preview($subject, $abstract, $story, $category); + submit_preview($subject, $abstract, $article, $category); break; case "Submit submission": - submit_submit($subject, $abstract, $story, $category); + submit_submit($subject, $abstract, $article, $category); break; default: submit_enter();