mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=2819
This commit is contained in:
parent
a1d9e8439c
commit
645f77de1b
|
@ -8593,3 +8593,35 @@ David 20 Dec 2003
|
|||
|
||||
client/win/
|
||||
wingui_mainwindow.cpp,h
|
||||
|
||||
David 20 Dec 2003
|
||||
- compute recent average credit correctly
|
||||
- compute "activity" for questions in a reasonable way:
|
||||
the number of times per day this question has been asked
|
||||
- default sort order for questions is by descending activity
|
||||
- added fulltext indices on profile.response1 and profile.response2
|
||||
- added text search of profiles to web interface
|
||||
- link to list of a user's posts from their user page
|
||||
- generate UOD page even if already there
|
||||
- clean up some PHP code:
|
||||
use $foo->bar, not $foo['bar']
|
||||
indent by 4 spaces
|
||||
|
||||
db/
|
||||
constraints.sql
|
||||
schema.sql
|
||||
html_ops/
|
||||
gallery.inc
|
||||
update_forum_activities.php
|
||||
html_user/
|
||||
profile_menu.php
|
||||
user.inc
|
||||
util.inc
|
||||
profile_search_action.php (new)
|
||||
forum/
|
||||
forum.inc
|
||||
forum.php
|
||||
text_search_action.php
|
||||
user_posts.php (new)
|
||||
sched/
|
||||
sched_util.C
|
||||
|
|
|
@ -86,6 +86,7 @@ alter table host
|
|||
-- db_dump.C
|
||||
|
||||
alter table profile
|
||||
add fulltext index profile_reponse(response1, reponse2),
|
||||
add unique profile_userid(userid);
|
||||
|
||||
alter table subscriptions
|
||||
|
@ -95,4 +96,6 @@ alter table thread
|
|||
add fulltext index thread_title(title);
|
||||
|
||||
alter table post
|
||||
add index post_user (user),
|
||||
add index post_thread (thread),
|
||||
add fulltext index post_content(content);
|
||||
|
|
|
@ -287,7 +287,7 @@ create table forum (
|
|||
primary key (id)
|
||||
);
|
||||
|
||||
-- threads in a topic
|
||||
-- threads in a topic (or questions)
|
||||
--
|
||||
create table thread (
|
||||
id integer not null auto_increment,
|
||||
|
@ -300,8 +300,9 @@ create table thread (
|
|||
-- number of times this has been viewed
|
||||
replies integer not null,
|
||||
-- number of postings in thread
|
||||
activity integer not null,
|
||||
-- not used?? should remove references
|
||||
activity double not null,
|
||||
-- for questions: number of askers / time since asked
|
||||
(set periodically by update_forum_activity.php)
|
||||
sufferers integer not null,
|
||||
-- in help desk: # people who indicated they had same problem
|
||||
create_time integer not null,
|
||||
|
@ -309,7 +310,7 @@ create table thread (
|
|||
primary key (id)
|
||||
);
|
||||
|
||||
-- postings in a thread.
|
||||
-- postings in a thread (or answers)
|
||||
-- Each thread has an initial post
|
||||
--
|
||||
create table post (
|
||||
|
|
|
@ -21,8 +21,7 @@ $forum_sort_styles['replies-most'] = "Most posts first";
|
|||
|
||||
$faq_sort_styles['create_time'] = "Most recent question first";
|
||||
$faq_sort_styles['timestamp'] = "Most recent answer first";
|
||||
$faq_sort_styles['sufferers'] = "Most often asked first";
|
||||
$faq_sort_styles['activity'] = "Highest score first";
|
||||
$faq_sort_styles['activity'] = "Most often asked first";
|
||||
|
||||
$answer_sort_styles['score'] = "Highest score first";
|
||||
$answer_sort_styles['timestamp'] = "Most recent first";
|
||||
|
@ -454,4 +453,63 @@ function show_forum_title($forum=NULL, $thread=NULL, $helpdesk=false) {
|
|||
echo "</p>\n";
|
||||
}
|
||||
|
||||
// show a thread with its context (e.g. for search results)
|
||||
//
|
||||
function show_thread($thread, $n) {
|
||||
$forum = getForum($thread->forum);
|
||||
$category = getCategory($forum->category);
|
||||
$first_post = getFirstPost($thread->id);
|
||||
$title = stripslashes($thread->title);
|
||||
$where = $category->is_helpdesk?"Questions and answers":"Message boards";
|
||||
$top_url = $category->is_helpdesk?"help_desk.php":"index.php";
|
||||
$excerpt = sub_sentence(stripslashes($first_post->content), ' ', EXCERPT_LENGTH, true);
|
||||
$posted = time_diff_str($thread->create_time, time());
|
||||
$last = time_diff_str($thread->timestamp, time());
|
||||
$m = $n%2;
|
||||
echo "
|
||||
<tr class=row$m>
|
||||
<td><font size=-2>
|
||||
$n) Posted $posted
|
||||
<br>
|
||||
Last response $last
|
||||
</td>
|
||||
<td valign=top>
|
||||
<a href=$top_url>$where</a> : $category->name :
|
||||
<a href=forum.php?id=$forum->id>$forum->title</a> :
|
||||
<a href=thread.php?id=$thread->id>$title</a>
|
||||
<br>
|
||||
<font size=-2>$excerpt</font>
|
||||
</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
|
||||
// show a post with its context (e.g. for search results)
|
||||
//
|
||||
function show_post2($post, $n) {
|
||||
$thread = getThread($post->thread);
|
||||
$forum = getForum($thread->forum);
|
||||
$category = getCategory($forum->category);
|
||||
$where = $category->is_helpdesk?"Questions and answers":"Message boards";
|
||||
$top_url = $category->is_helpdesk?"help_desk.php":"index.php";
|
||||
$content = nl2br(stripslashes($post->content));
|
||||
$when = time_diff_str($post->timestamp, time());
|
||||
$user = lookup_user_id($post->user);
|
||||
$title = stripslashes($thread->title);
|
||||
$m = $n%2;
|
||||
echo "
|
||||
<tr class=row$m>
|
||||
<td>
|
||||
$n) <a href=$top_url>$where</a> : $category->name :
|
||||
<a href=forum.php?id=$forum->id>$forum->title</a> :
|
||||
<a href=thread.php?id=$thread->id>$title</a>
|
||||
<br>
|
||||
Posted $when by $user->name
|
||||
<hr>
|
||||
$content
|
||||
</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -27,7 +27,7 @@ $category = getCategory($forum->category);
|
|||
if ($category->is_helpdesk) {
|
||||
page_head('Help Desk');
|
||||
$sort_style = $_GET['sort'];
|
||||
if (!$sort_style) $sort_style = 'sufferers';
|
||||
if (!$sort_style) $sort_style = 'activity';
|
||||
} else {
|
||||
page_head('Message boards : '.$forum->title);
|
||||
$sort_style = $_GET['sort'];
|
||||
|
@ -85,7 +85,7 @@ while($thread = mysql_fetch_object($threads)) {
|
|||
$first_post = getFirstPost($thread->id);
|
||||
$excerpt = sub_sentence($first_post->content, ' ', EXCERPT_LENGTH, true);
|
||||
echo "
|
||||
<tr class=\"row$n\" style=\"font-size:8pt; text-align:center\">
|
||||
<tr class=row$n style=\"font-size:8pt; text-align:center\">
|
||||
<td style=\"font-size:10pt; text-align:left\"><a href=\"thread.php?id=", $thread->id, "\"><b>", stripslashes($thread->title), "</b></a><br>
|
||||
";
|
||||
$n = ($n+1)%2;
|
||||
|
|
|
@ -10,61 +10,6 @@ $count = 10;
|
|||
|
||||
page_head("Search results");
|
||||
|
||||
function show_thread($thread, $n) {
|
||||
$forum = getForum($thread->forum);
|
||||
$category = getCategory($forum->category);
|
||||
$first_post = getFirstPost($thread->id);
|
||||
$title = stripslashes($thread->title);
|
||||
$where = $category->is_helpdesk?"Questions and answers":"Message boards";
|
||||
$top_url = $category->is_helpdesk?"help_desk.php":"index.php";
|
||||
$excerpt = sub_sentence(stripslashes($first_post->content), ' ', EXCERPT_LENGTH, true);
|
||||
$posted = time_diff_str($thread->create_time, time());
|
||||
$last = time_diff_str($thread->timestamp, time());
|
||||
$m = $n%2;
|
||||
echo "
|
||||
<tr class=row$m>
|
||||
<td><font size=-2>
|
||||
$n) Posted $posted
|
||||
<br>
|
||||
Last response $last
|
||||
</td>
|
||||
<td valign=top>
|
||||
<a href=$top_url>$where</a> : $category->name :
|
||||
<a href=forum.php?id=$forum->id>$forum->title</a> :
|
||||
<a href=thread.php?id=$thread->id>$title</a>
|
||||
<br>
|
||||
<font size=-2>$excerpt</font>
|
||||
</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
|
||||
function show_post2($post, $n) {
|
||||
$thread = getThread($post->thread);
|
||||
$forum = getForum($thread->forum);
|
||||
$category = getCategory($forum->category);
|
||||
$where = $category->is_helpdesk?"Questions and answers":"Message boards";
|
||||
$top_url = $category->is_helpdesk?"help_desk.php":"index.php";
|
||||
$content = nl2br(stripslashes($post->content));
|
||||
$when = time_diff_str($post->timestamp, time());
|
||||
$user = lookup_user_id($post->user);
|
||||
$title = stripslashes($thread->title);
|
||||
$m = $n%2;
|
||||
echo "
|
||||
<tr class=row$m>
|
||||
<td>
|
||||
$n) <a href=$top_url>$where</a> : $category->name :
|
||||
<a href=forum.php?id=$forum->id>$forum->title</a> :
|
||||
<a href=thread.php?id=$thread->id>$title</a>
|
||||
<br>
|
||||
Posted $when by $user->name
|
||||
<hr>
|
||||
$content
|
||||
</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
|
||||
if ($_GET['titles']) {
|
||||
echo "<h2>Titles containing '$search_string'</h2>\n";
|
||||
$q = "select * from thread where match(title) against ('$search_string') limit $offset,$count";
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
require_once('../util.inc');
|
||||
require_once('../time.inc');
|
||||
require_once('forum.inc');
|
||||
|
||||
db_init('../');
|
||||
|
||||
$userid = $_GET['userid'];
|
||||
|
||||
$user = lookup_user_id($userid);
|
||||
|
||||
page_head("Posts by $user->name");
|
||||
$result = mysql_query("select * from post where user=$userid order by id desc");
|
||||
$n = 1;
|
||||
echo "<table>\n";
|
||||
while($post = mysql_fetch_object($result)) {
|
||||
show_post2($post, $n);
|
||||
$n++;
|
||||
}
|
||||
echo "</table>\n";
|
||||
mysql_free_result($result);
|
||||
|
||||
?>
|
|
@ -5,7 +5,9 @@ require_once("../html_user/profile.inc");
|
|||
require_once("../html_user/util.inc");
|
||||
|
||||
|
||||
// OK, so it's not quite the alphabet, but alphanumerabet is a bad variable name.
|
||||
// OK, so it's not quite the alphabet,
|
||||
// but alphanumerabet is a bad variable name.
|
||||
//
|
||||
$alphabet = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9');
|
||||
|
||||
// Generates the html files which comprise the photo gallery.
|
||||
|
@ -14,82 +16,93 @@ $alphabet = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P
|
|||
// $height: the height of the table of images.
|
||||
function build_picture_pages($width, $height) {
|
||||
|
||||
// TODO: Add support for a computer image gallery.
|
||||
// TODO: Add support for a computer image gallery.
|
||||
|
||||
// TODO: Should we eliminate the has_picture flag? Doesn't really
|
||||
// seem necessary when we're building static pages- could just use
|
||||
// file_exists on the username...
|
||||
// TODO: Should we eliminate the has_picture flag? Doesn't really
|
||||
// seem necessary when we're building static pages- could just use
|
||||
// file_exists on the username...
|
||||
|
||||
// TODO: Standardize "Last modified" string to a function call (util.inc).
|
||||
// TODO: Standardize "Last modified" string to a function call (util.inc).
|
||||
|
||||
$query = "SELECT userid FROM profile WHERE has_picture = 1";
|
||||
$result = mysql_query($query);
|
||||
$numIds = mysql_num_rows($result);
|
||||
$query = "SELECT userid FROM profile WHERE has_picture = 1";
|
||||
$result = mysql_query($query);
|
||||
$numIds = mysql_num_rows($result);
|
||||
|
||||
//echo "Result has $numIds rows.<br>";
|
||||
//echo "Result has $numIds rows.<br>";
|
||||
|
||||
// Build an array of IDs of all users with pictures in their profiles.
|
||||
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
|
||||
$userIds[] = $row[0];
|
||||
}
|
||||
|
||||
mysql_free_result($result);
|
||||
|
||||
if (count($userIds) > 0) {
|
||||
// Randomize the ordering of users.
|
||||
shuffle($userIds);
|
||||
}
|
||||
|
||||
$numPages = ceil(count($userIds)/($width * $height));
|
||||
|
||||
// Make sure that a page is generated even when no profiles with pictures
|
||||
// exist in order to avoid 404 errors from the profile_menu page.
|
||||
|
||||
if ($numPages == 0) {
|
||||
$numPages = 1;
|
||||
}
|
||||
|
||||
//echo "Generating $numPages pages.<br>";
|
||||
|
||||
$count = 0;
|
||||
|
||||
for ($page = 1; $page <= $numPages; $page++) {
|
||||
$file = "../html_user/" . PROFILE_PATH . "user_gallery_" . $page . ".html";
|
||||
$descriptor = fopen($file, "w");
|
||||
|
||||
page_head("User Picture Gallery: Page $page of $numPages", null, $descriptor);
|
||||
|
||||
fwrite($descriptor, "<h2>User Profile Pictures</h2>Last updated " . pretty_time_str(time()) . "\n<p>Browse the user profiles by picture. Only user profiles with pictures are listed here.");
|
||||
|
||||
fwrite($descriptor, "<table class=bordered border=1 cellpadding=5>\n");
|
||||
|
||||
for ($row = 0; $row < $height; $row++) {
|
||||
fwrite($descriptor, "<tr>");
|
||||
for ($col = 0; $col < $width; $col++) {
|
||||
if ($count < $numIds) {
|
||||
|
||||
fwrite($descriptor, "<td class=bordered align=\"center\"><a href=\"" . URL_BASE . "view_profile.php?userid=" . $userIds[$count] . "\"><img src=\"" . '../' . IMAGE_PATH . $userIds[$count] . '_sm.jpg' . "\"></a></td>");
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
fwrite($descriptor, "</tr>\n");
|
||||
if ($count == $numIds) {
|
||||
break;
|
||||
}
|
||||
// Build an array of IDs of all users with pictures in their profiles.
|
||||
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
|
||||
$userIds[] = $row[0];
|
||||
}
|
||||
|
||||
fwrite($descriptor, "</table>\n");
|
||||
mysql_free_result($result);
|
||||
|
||||
// Previous and Next links
|
||||
if (count($userIds) > 0) {
|
||||
// Randomize the ordering of users.
|
||||
shuffle($userIds);
|
||||
}
|
||||
|
||||
write_page_links("user_gallery", $page, $numPages, $descriptor);
|
||||
$numPages = ceil(count($userIds)/($width * $height));
|
||||
|
||||
page_tail($descriptor);
|
||||
// Make sure that a page is generated even when no profiles with pictures
|
||||
// exist in order to avoid 404 errors from the profile_menu page.
|
||||
|
||||
fclose($descriptor);
|
||||
if ($numPages == 0) {
|
||||
$numPages = 1;
|
||||
}
|
||||
|
||||
}
|
||||
//echo "<br><br><a href=\"" . "../html_user/" .PROFILE_PATH . "user_gallery_1.html\">Go to the first generated page.</a>";
|
||||
//echo "Generating $numPages pages.<br>";
|
||||
|
||||
$count = 0;
|
||||
|
||||
for ($page = 1; $page <= $numPages; $page++) {
|
||||
$file = "../html_user/" . PROFILE_PATH . "user_gallery_" . $page . ".html";
|
||||
$descriptor = fopen($file, "w");
|
||||
|
||||
page_head("User Picture Gallery: Page $page of $numPages", null, $descriptor);
|
||||
|
||||
fwrite($descriptor,
|
||||
"<h2>User Profile Pictures</h2>Last updated "
|
||||
. pretty_time_str(time())
|
||||
. "\n<p>Browse the user profiles by picture.
|
||||
Only user profiles with pictures are listed here."
|
||||
);
|
||||
|
||||
fwrite($descriptor, "<table class=bordered border=1 cellpadding=5>\n");
|
||||
|
||||
for ($row = 0; $row < $height; $row++) {
|
||||
fwrite($descriptor, "<tr>");
|
||||
for ($col = 0; $col < $width; $col++) {
|
||||
if ($count < $numIds) {
|
||||
fwrite($descriptor,
|
||||
"<td class=bordered align=\"center\"><a href=\""
|
||||
. URL_BASE . "view_profile.php?userid="
|
||||
. $userIds[$count] . "\"><img src=\"" . '../'
|
||||
. IMAGE_PATH . $userIds[$count] . '_sm.jpg'
|
||||
. "\"></a></td>"
|
||||
);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
fwrite($descriptor, "</tr>\n");
|
||||
if ($count == $numIds) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fwrite($descriptor, "</table>\n");
|
||||
|
||||
// Previous and Next links
|
||||
|
||||
write_page_links("user_gallery", $page, $numPages, $descriptor);
|
||||
|
||||
page_tail($descriptor);
|
||||
|
||||
fclose($descriptor);
|
||||
|
||||
}
|
||||
|
||||
//echo "<br><br><a href=\"" . "../html_user/" .PROFILE_PATH . "user_gallery_1.html\">Go to the first generated page.</a>";
|
||||
}
|
||||
|
||||
// Creates pages grouping user profiles by country. Filenames are of the
|
||||
|
@ -99,51 +112,55 @@ function build_picture_pages($width, $height) {
|
|||
// each country.
|
||||
|
||||
function build_country_pages() {
|
||||
$query = "SELECT * FROM profile";
|
||||
$result = mysql_query($query);
|
||||
$numIds = 0;
|
||||
|
||||
$query = "SELECT * FROM profile";
|
||||
$result = mysql_query($query);
|
||||
$numIds = 0;
|
||||
// Build a multi-dimensional array of countries,
|
||||
// each element of which contains an array
|
||||
// of the userids who belong to those countries.
|
||||
// Format: array[country][index] = userid.
|
||||
|
||||
// Build a multi-dimensional array of countries, each element of which contains an array
|
||||
// of the userids who belong to those countries. Format: array[country][index] = userid.
|
||||
while ($profile = mysql_fetch_object($result)) {
|
||||
$query2 = "SELECT * FROM user WHERE id=$profile->userid";
|
||||
$result2 = mysql_query($query2);
|
||||
$row2 = mysql_fetch_object($result2);
|
||||
|
||||
while ($row = mysql_fetch_assoc($result)) {
|
||||
$query2 = "SELECT * FROM user WHERE id = " . $row['userid'];
|
||||
$result2 = mysql_query($query2);
|
||||
$row2 = mysql_fetch_assoc($result2);
|
||||
|
||||
if ($row2['country']) {
|
||||
$countryMembers[$row2['country']][] = $row2['id'];
|
||||
$numIds++;
|
||||
} else {
|
||||
$countryMembers['Other'][] = $row2['id'];
|
||||
if ($row2->country) {
|
||||
$countryMembers[$row2->country][] = $row2->id;
|
||||
$numIds++;
|
||||
} else {
|
||||
$countryMembers['Other'][] = $row2->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mysql_free_result($result);
|
||||
mysql_free_result($result2);
|
||||
mysql_free_result($result);
|
||||
mysql_free_result($result2);
|
||||
|
||||
//echo "$numIds users have profiles AND non-null country entries.<br>";
|
||||
//echo "$numIds users have profiles AND non-null country entries.<br>";
|
||||
|
||||
$countries = array_keys($countryMembers);
|
||||
sort($countries);
|
||||
$countries = array_keys($countryMembers);
|
||||
sort($countries);
|
||||
|
||||
// Build the pages.
|
||||
// TODO: Define a constant for the desired number of rows per page.
|
||||
// Build the pages.
|
||||
// TODO: Define a constant for the desired number of rows per page.
|
||||
|
||||
foreach ($countries as $country) {
|
||||
$baseFileName = "profile_country_" . get_legal_filename($country);
|
||||
$filePath = "../html_user/" . PROFILE_PATH;
|
||||
build_profile_pages($countryMembers[$country], "User Profiles from $country", $country, 5, 2, $filePath, $baseFileName, "../html_user/");
|
||||
foreach ($countries as $country) {
|
||||
$baseFileName = "profile_country_" . get_legal_filename($country);
|
||||
$filePath = "../html_user/" . PROFILE_PATH;
|
||||
build_profile_pages(
|
||||
$countryMembers[$country],
|
||||
"User Profiles from $country", $country, 5, 2,
|
||||
$filePath, $baseFileName, "../html_user/"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
// Build the summary page linking to the individual country pages.
|
||||
|
||||
// Build the summary page linking to the individual country pages.
|
||||
build_country_summary_page($countryMembers);
|
||||
|
||||
build_country_summary_page($countryMembers);
|
||||
|
||||
//echo "<br><a href=\"" . "../html_user/" . PROFILE_PATH . "profile_country.html\">View Summary Page</a>";
|
||||
//echo "<br><br>Done";
|
||||
//echo "<br><a href=\"" . "../html_user/" . PROFILE_PATH . "profile_country.html\">View Summary Page</a>";
|
||||
//echo "<br><br>Done";
|
||||
|
||||
}
|
||||
|
||||
|
@ -179,9 +196,19 @@ function build_alpha_pages() {
|
|||
// NOTE: Array indexing is case sensitive.
|
||||
$filePath = "../html_user/" . PROFILE_PATH;
|
||||
if (in_array($letter, $alphabet)) {
|
||||
build_profile_pages($members[$letter], "User Profiles - Names beginning with $letter", "Names beginning with $letter", 5, 2, $filePath, "profile_$letter");
|
||||
build_profile_pages(
|
||||
$members[$letter],
|
||||
"User Profiles - Names beginning with $letter",
|
||||
"Names beginning with $letter", 5, 2, $filePath,
|
||||
"profile_$letter"
|
||||
);
|
||||
} else {
|
||||
build_profile_pages($members[$letter], "User Profiles - Names beginning with other characters", "Names beginning with other characters", 5, 2, $filePath, "profile_other");
|
||||
build_profile_pages(
|
||||
$members[$letter],
|
||||
"User Profiles - Names beginning with other characters",
|
||||
"Names beginning with other characters", 5, 2, $filePath,
|
||||
"profile_other"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -222,28 +249,31 @@ function build_profile_pages($members, $pageHead, $pageTitle, $rowsPerPage, $col
|
|||
}
|
||||
|
||||
function build_country_summary_page($countryMembers) {
|
||||
$countries = array_keys($countryMembers);
|
||||
$countries = array_keys($countryMembers);
|
||||
|
||||
$filename = "../html_user/" . PROFILE_PATH . "profile_country.html";
|
||||
$descriptor = fopen($filename, "w");
|
||||
$filename = "../html_user/" . PROFILE_PATH . "profile_country.html";
|
||||
$descriptor = fopen($filename, "w");
|
||||
|
||||
page_head("User Profiles by Country", null, $descriptor);
|
||||
fwrite($descriptor, "<h2>User Profiles by Country</h2>Last updated " . pretty_time_str(time()) . "<p>");
|
||||
page_head("User Profiles by Country", null, $descriptor);
|
||||
fwrite($descriptor, "<h2>User Profiles by Country</h2>Last updated " . pretty_time_str(time()) . "<p>");
|
||||
|
||||
fwrite($descriptor, "<table border=0>\n");
|
||||
fwrite($descriptor, "<tr><td><b>Country</b></td><td align=\"center\"><b>Profiles</b></td></tr>\n");
|
||||
fwrite($descriptor, "<table border=0>\n");
|
||||
fwrite($descriptor, "<tr><td><b>Country</b></td><td align=\"center\"><b>Profiles</b></td></tr>\n");
|
||||
|
||||
foreach ($countries as $country) {
|
||||
$numMembers = count($countryMembers[$country]);
|
||||
$name = get_legal_filename($country);
|
||||
foreach ($countries as $country) {
|
||||
$numMembers = count($countryMembers[$country]);
|
||||
$name = get_legal_filename($country);
|
||||
|
||||
fwrite($descriptor, "<tr>\n<td><a href=\"profile_country_" . $name . "_1.html\">$country</a></td><td align=\"center\">$numMembers</td></td>\n");
|
||||
}
|
||||
fwrite($descriptor,
|
||||
"<tr>\n<td><a href=\"profile_country_"
|
||||
. $name . "_1.html\">$country</a></td><td align=\"center\">$numMembers</td></td>\n"
|
||||
);
|
||||
}
|
||||
|
||||
fwrite($descriptor, "</table>");
|
||||
page_tail($descriptor);
|
||||
fwrite($descriptor, "</table>");
|
||||
page_tail($descriptor);
|
||||
|
||||
fclose($descriptor);
|
||||
fclose($descriptor);
|
||||
}
|
||||
|
||||
function build_alpha_summary_page($characters) {
|
||||
|
@ -268,16 +298,34 @@ function build_alpha_summary_page($characters) {
|
|||
fclose($descriptor);
|
||||
}
|
||||
|
||||
function generate_uod_page($profile, $user) {
|
||||
$filename = "../html_user/uotd.html";
|
||||
$descriptor = fopen($filename, "w");
|
||||
|
||||
if ($profile->has_picture) {
|
||||
fwrite($descriptor,
|
||||
"<a href=view_profile?userid=$user->id><img align=left src=" . IMAGE_PATH . $user->id . "_sm.jpg></a>"
|
||||
);
|
||||
}
|
||||
$x = user_links($user);
|
||||
fwrite($descriptor, "The " . PROJECT . " User of the Day is $x");
|
||||
fclose($descriptor);
|
||||
}
|
||||
|
||||
// see if it's time to pick a new UOD.
|
||||
// Either way, generate the UOD page
|
||||
//
|
||||
function build_uotd_page() {
|
||||
// Check if the current UOTD has had their 24 hours of fame - if so, pick a new one.
|
||||
|
||||
$result = mysql_query("SELECT * FROM profile ORDER BY uotd_time DESC LIMIT 1");
|
||||
if (mysql_num_rows($result) > 0) {
|
||||
$current_uotd = mysql_fetch_assoc($result);
|
||||
$assigned = getdate($current_uotd['uotd_time']);
|
||||
$current_uotd = mysql_fetch_object($result);
|
||||
$assigned = getdate($current_uotd->uotd_time);
|
||||
$now = getdate(time());
|
||||
if ($assigned['mday'] == $now['mday']) {
|
||||
$user = lookup_user_id($current_uotd->userid);
|
||||
generate_uod_page($current_uotd, $user);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
@ -298,25 +346,18 @@ function build_uotd_page() {
|
|||
// No valid users of the day - do something.
|
||||
exit();
|
||||
}
|
||||
$profile = mysql_fetch_assoc($result);
|
||||
$profile = mysql_fetch_object($result);
|
||||
$user = lookup_user_id($profile->userid);
|
||||
generate_uod_page($profile);
|
||||
|
||||
$sql = "SELECT * FROM user where id = " . $profile['userid'];
|
||||
$result2 = mysql_query($sql);
|
||||
$user = mysql_fetch_assoc($result2);
|
||||
|
||||
$filename = "../html_user/uotd.html";
|
||||
$descriptor = fopen($filename, "w");
|
||||
|
||||
if ($profile['has_picture']) {
|
||||
fwrite($descriptor, "<a href=\"view_profile?userid=" . $user['id'] . "\"><img align=\"left\" src=\"" . IMAGE_PATH . $user['id'] . "_sm.jpg\"</img></a>");
|
||||
}
|
||||
fwrite($descriptor, "The " . PROJECT . " User of the Day is <a href=\"view_profile?userid=" . $user['id'] . "\">" . $user['name'] . "</a>!");
|
||||
fclose($descriptor);
|
||||
|
||||
$sql = "UPDATE profile SET uotd_time = " . time() . " WHERE userid = " . $user['id'];
|
||||
$sql = "UPDATE profile SET uotd_time = " . time() . " WHERE userid=$user->id";
|
||||
mysql_query($sql);
|
||||
|
||||
mail($user['email_addr'], "You're the " . PROJECT . " user of the day!", "Congratulations!\n\nYou've been chosen as the " . PROJECT . " user of the day! Your profile will be featured on the " . PROJECT . " website for the next 24 hours. Thanks again for supporting us- it's members like you that make distributed computing projects like ours such a success.\n\nBest regards and much thanks,\n\nThe " . PROJECT . " team.");
|
||||
mail($user->email_addr,
|
||||
"You're the " . PROJECT . " user of the day!",
|
||||
"Congratulations!\n\nYou've been chosen as the "
|
||||
. PROJECT . " user of the day! Your profile will be featured on the " . PROJECT . " website for the next 24 hours. Thanks again for supporting us- it's members like you that make distributed computing projects like ours such a success.\n\nBest regards and much thanks,\n\nThe " . PROJECT . " team."
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,53 +1,41 @@
|
|||
#!/usr/local/bin/php
|
||||
<?php
|
||||
|
||||
require_once("../html_user/db.inc");
|
||||
require_once("../html_user/util.inc");
|
||||
require_once("forum.inc");
|
||||
|
||||
define('MAX_REWARD', 4096);
|
||||
define('SCALAR', 0.9);
|
||||
|
||||
db_init();
|
||||
db_init("../");
|
||||
|
||||
$currentTime = time();
|
||||
$result = mysql_query("SELECT * FROM thread");
|
||||
$now = time();
|
||||
$result = mysql_query("select * FROM thread");
|
||||
|
||||
while ($thread = mysql_fetch_assoc($result)) {
|
||||
$sql = "SELECT * FROM forum WHERE id = " . $thread['forum'];
|
||||
$result3 = mysql_query($sql);
|
||||
$forum = NULL;
|
||||
|
||||
if ($result3) {
|
||||
$forum = mysql_fetch_assoc($result3);
|
||||
}
|
||||
|
||||
// Helpdesk activity is scaled linearly by the number of days since the last post.
|
||||
if ($forum != NULL && $forum['is_helpdesk']) {
|
||||
$timeDiff = $currentTime - $thread['timestamp'];
|
||||
$dayDiff = floor($timeDiff / 86400); // 86400 = # of seconds in a day;
|
||||
$points = $thread['sufferers'];
|
||||
if ($dayDiff > 0) {
|
||||
$points = $points * ($dayDiff * SCALAR);
|
||||
}
|
||||
// Other forum activity is scaled exponentially based on the recency of the posts.
|
||||
while ($thread = mysql_fetch_object($result)) {
|
||||
$forum = getForum($thread->forum);
|
||||
$category = getCategory($forum->category);
|
||||
if ($category->is_helpdesk) {
|
||||
$diff = ($now - $thread->create_time)/86400;
|
||||
$activity = ($thread->sufferers+1)/$diff;
|
||||
echo "help $diff $activity\n";
|
||||
} else {
|
||||
$sql = "SELECT * FROM post WHERE thread = " . $thread['id'];
|
||||
$sql = "select * from post where thread=$thread->id";
|
||||
$result2 = mysql_query($sql);
|
||||
$points = 0;
|
||||
$activity = 0;
|
||||
|
||||
while ($post = mysql_fetch_assoc($result2)) {
|
||||
$timeDiff = $currentTime - $post['timestamp'];
|
||||
$dayDiff = floor($timeDiff / 86400);
|
||||
|
||||
$points += (MAX_REWARD / pow(2, $dayDiff));
|
||||
while ($post = mysql_fetch_object($result2)) {
|
||||
$diff = $now - $post->timestamp;
|
||||
$diff /= 7*86400;
|
||||
$activity += pow(2, -$diff);
|
||||
}
|
||||
echo "forum $activity\n";
|
||||
}
|
||||
|
||||
$sql = "UPDATE thread SET activity = " . ceil($points) . " WHERE id = " . $thread['id'];
|
||||
$sql = "update thread set activity=$activity where id=$thread->id";
|
||||
mysql_query($sql);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -17,9 +17,14 @@ page_head("Profile Zone");
|
|||
|
||||
start_table_noborder();
|
||||
rowify("
|
||||
User profiles provide a way for individuals to share backgrounds and opinions with the " . PROJECT . " community. Explore the diversity of your fellow searchers, and contribute your own views for others to enjoy.
|
||||
<p>
|
||||
If you haven't already, you can <a href=create_profile.php>create your own user profile</a> for others to see!
|
||||
User profiles provide a way for individuals to share backgrounds
|
||||
and opinions with the " . PROJECT . " community.
|
||||
Explore the diversity of your fellow searchers,
|
||||
and contribute your own views for others to enjoy.
|
||||
<p>
|
||||
If you haven't already, you can
|
||||
<a href=create_profile.php>create your own user profile</a>
|
||||
for others to see!
|
||||
");
|
||||
rowify("<br>");
|
||||
|
||||
|
@ -33,97 +38,103 @@ echo "</td></tr>";
|
|||
rowify("<br>");
|
||||
row1("User Profile Explorer");
|
||||
echo "<tr><td>
|
||||
<ul>
|
||||
<li>View the <a href=" . PROFILE_PATH . "user_gallery_1.html>User Picture Gallery</a>.
|
||||
<li>Browse profiles <a href=" . PROFILE_PATH . "profile_country.html>by country</a>.
|
||||
<li>Browse profiles <a href=" . $_SERVER['PHP_SELF'] . "?cmd=rand&pic=-1>at random</a>,
|
||||
<a href=" . $_SERVER['PHP_SELF'] . "?cmd=rand&pic=1>at random with pictures</a>, or
|
||||
<a href=" . $_SERVER['PHP_SELF'] . "?cmd=rand&pic=0>at random without pictures</a>.
|
||||
<ul>
|
||||
<li>View the <a href=" . PROFILE_PATH . "user_gallery_1.html>User Picture Gallery</a>.
|
||||
<li>Browse profiles <a href=" . PROFILE_PATH . "profile_country.html>by country</a>.
|
||||
<li>Browse profiles <a href=" . $_SERVER['PHP_SELF'] . "?cmd=rand&pic=-1>at random</a>,
|
||||
<a href=" . $_SERVER['PHP_SELF'] . "?cmd=rand&pic=1>at random with pictures</a>, or
|
||||
<a href=" . $_SERVER['PHP_SELF'] . "?cmd=rand&pic=0>at random without pictures</a>.
|
||||
|
||||
<li>Alphabetical profile listings <i></i>:<br>
|
||||
";
|
||||
|
||||
<li>Alphabetical profile listings <i></i>:<br>";
|
||||
include "profile_alpha.html";
|
||||
|
||||
echo "<br></ul></td></tr>";
|
||||
|
||||
rowify("<br>");
|
||||
row1("Name Search");
|
||||
rowify("<br>");
|
||||
row1("Search user names");
|
||||
|
||||
rowify("
|
||||
<form action=".$_SERVER['PHP_SELF']." method=GET>
|
||||
<input type=hidden name=cmd value=search>
|
||||
<input name=uname>
|
||||
<input type=submit value=OK>
|
||||
</form>
|
||||
");
|
||||
row1("Search profile text");
|
||||
rowify("
|
||||
<form action=profile_search_action.php method=GET>
|
||||
<input name=search_string>
|
||||
<input type=submit value=OK>
|
||||
</form>
|
||||
");
|
||||
end_table();
|
||||
|
||||
|
||||
echo "
|
||||
<form action=", $_SERVER['PHP_SELF'], " method=\"GET\">
|
||||
<input type=\"hidden\" name=\"cmd\" value=\"search\">
|
||||
<input type=\"text\" name=\"name\">
|
||||
<input type=\"submit\" value=\"Submit\">
|
||||
</form>";
|
||||
|
||||
end_table();
|
||||
page_tail();
|
||||
|
||||
function execute_command() {
|
||||
|
||||
// Request for a random profile.
|
||||
if ($_GET['cmd'] == "rand") {
|
||||
|
||||
if ($_GET['pic'] == 0) {
|
||||
$result = mysql_query("SELECT userid FROM profile WHERE has_picture = 0");
|
||||
} else if ($_GET['pic'] == 1) {
|
||||
$result = mysql_query("SELECT userid FROM profile WHERE has_picture = 1");
|
||||
} else if ($_GET['pic'] == -1) {
|
||||
$result = mysql_query("SELECT userid FROM profile");
|
||||
}
|
||||
// Request for a random profile.
|
||||
//
|
||||
if ($_GET['cmd'] == "rand") {
|
||||
if ($_GET['pic'] == 0) {
|
||||
$result = mysql_query("SELECT userid FROM profile WHERE has_picture=0");
|
||||
} else if ($_GET['pic'] == 1) {
|
||||
$result = mysql_query("SELECT userid FROM profile WHERE has_picture=1");
|
||||
} else if ($_GET['pic'] == -1) {
|
||||
$result = mysql_query("SELECT userid FROM profile");
|
||||
}
|
||||
|
||||
while ($row = mysql_fetch_row($result)) {
|
||||
$userIds[] = $row[0];
|
||||
}
|
||||
while ($row = mysql_fetch_row($result)) {
|
||||
$userIds[] = $row[0];
|
||||
}
|
||||
|
||||
if (count($userIds) == 0) {
|
||||
echo "No profiles matched your query.<br>";
|
||||
exit();
|
||||
if (count($userIds) == 0) {
|
||||
echo "No profiles matched your query.<br>";
|
||||
exit();
|
||||
}
|
||||
|
||||
shuffle($userIds);
|
||||
header("Location: " . URL_BASE . "view_profile.php?userid=" . $userIds[0]);
|
||||
exit();
|
||||
}
|
||||
|
||||
shuffle($userIds);
|
||||
|
||||
header("Location: " . URL_BASE . "view_profile.php?userid=" . $userIds[0]);
|
||||
exit();
|
||||
}
|
||||
|
||||
else if ($_GET['cmd'] == "search") {
|
||||
else if ($_GET['cmd'] == "search") {
|
||||
|
||||
if ($_GET['name']) {
|
||||
$result = mysql_query("SELECT id FROM user WHERE name LIKE \"%" . $_GET['name'] . "%\"");
|
||||
|
||||
while($row = mysql_fetch_assoc($result)) {
|
||||
$result2 = mysql_query("SELECT userid FROM profile WHERE userid = " . $row['id']);
|
||||
if ($result2) {
|
||||
$row2 = mysql_fetch_assoc($result2);
|
||||
if ($_GET['name']) {
|
||||
$result = mysql_query("SELECT id FROM user WHERE name LIKE \"%" . $_GET['uname'] . "%\"");
|
||||
while($row = mysql_fetch_assoc($result)) {
|
||||
$result2 = mysql_query("SELECT userid FROM profile WHERE userid = " . $row['id']);
|
||||
if ($result2) {
|
||||
$row2 = mysql_fetch_assoc($result2);
|
||||
|
||||
if ($row2['userid']) {
|
||||
$members[] = $row2['userid'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
show_search_results($members);
|
||||
if ($row2['userid']) {
|
||||
$members[] = $row2['userid'];
|
||||
}
|
||||
}
|
||||
}
|
||||
show_search_results($members);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: This function should generate multiple pages, and should possibly take the number
|
||||
// of results to display from a user-input parameter. Look at build_profile_pages for an
|
||||
// example of a good way to do this (albeit writing to a file in that case).
|
||||
// TODO: This function should generate multiple pages,
|
||||
// and should possibly take the number of results to display
|
||||
// from a user-input parameter.
|
||||
// Look at build_profile_pages for an example of a good way to do this
|
||||
// (albeit writing to a file in that case).
|
||||
|
||||
function show_search_results($members) {
|
||||
page_head("Profile Search Results");
|
||||
page_head("Profile Search Results");
|
||||
|
||||
if (count($members) > 0) {
|
||||
show_user_table($members, 0, 20, 2);
|
||||
} else {
|
||||
echo "No profiles matched your query.<br>";
|
||||
}
|
||||
|
||||
page_tail();
|
||||
if (count($members) > 0) {
|
||||
show_user_table($members, 0, 20, 2);
|
||||
} else {
|
||||
echo "No profiles matched your query.<br>";
|
||||
}
|
||||
|
||||
page_tail();
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
require_once("db.inc");
|
||||
require_once("util.inc");
|
||||
|
||||
function show_profile($profile, $n) {
|
||||
$user = lookup_user_id($profile->userid);
|
||||
echo "<br>". user_links($user)."\n";
|
||||
}
|
||||
|
||||
db_init();
|
||||
|
||||
$search_string = $_GET['search_string'];
|
||||
$offset = $_GET['offset'];
|
||||
if (!$offset) $offset=0;
|
||||
$count = 10;
|
||||
|
||||
page_head("Search results");
|
||||
|
||||
echo "<h2>Profiles containing '$search_string'</h2>\n";
|
||||
$q = "select * from profile where match(response1, response2) against ('$search_string') limit $offset,$count";
|
||||
$result = mysql_query($q);
|
||||
echo "<table>";
|
||||
$n = 0;
|
||||
while ($profile = mysql_fetch_object($result)) {
|
||||
show_profile($profile, $n+$offset+1);
|
||||
$n += 1;
|
||||
}
|
||||
echo "</table>";
|
||||
mysql_free_result($result);
|
||||
if ($offset==0 && $n==0) {
|
||||
echo "No profiles found containing '$search_string'";
|
||||
}
|
||||
|
||||
if ($n==$count) {
|
||||
$s = urlencode($search_string);
|
||||
$offset += $count;
|
||||
echo "
|
||||
<a href=profile_search_action.php?search_string=$s&offset=$offset>Next $count</a>
|
||||
";
|
||||
|
||||
}
|
||||
|
||||
page_tail();
|
||||
?>
|
|
@ -26,6 +26,10 @@ function show_user_stats_private($user) {
|
|||
}
|
||||
row2("Computers", "<a href=hosts_user.php>View</a>");
|
||||
row2("Results", "<a href=results.php?userid=$user->id>View</a>");
|
||||
if ($user->posts) {
|
||||
row2("Message board posts", "<a href=forum/user_posts.php?userid=$user->id>$user->posts messages</a>");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// show static user info (private)
|
||||
|
@ -97,6 +101,9 @@ function show_user_summary_public($user) {
|
|||
} else {
|
||||
row2("Computers", "hidden");
|
||||
}
|
||||
if ($user->posts) {
|
||||
row2("Message boards posts", "<a href=forum/user_posts.php?userid=$user->id>$user->posts</a>");
|
||||
}
|
||||
}
|
||||
|
||||
// show a summary of the user.
|
||||
|
|
|
@ -187,8 +187,8 @@ function start_table($extra="") {
|
|||
echo "<table border=1 cellpadding=5 $extra>";
|
||||
}
|
||||
|
||||
function start_table_noborder($width=640) {
|
||||
echo "<table border=0 cellpadding=0 width=$width>";
|
||||
function start_table_noborder($width="100%") {
|
||||
echo "<table border=0 cellpadding=5 width=$width>";
|
||||
}
|
||||
|
||||
function end_table() {
|
||||
|
|
|
@ -86,21 +86,17 @@ void update_average(
|
|||
double& avg, // average credit per day (in and out)
|
||||
double& avg_time // when average was last computed
|
||||
) {
|
||||
time_t now = time(0);
|
||||
double now = dtime();
|
||||
|
||||
// decrease existing average according to how long it's been
|
||||
// since it was computed
|
||||
//
|
||||
if (avg_time) {
|
||||
double deltat = now - avg_time;
|
||||
avg *= exp(-deltat*LOG2/AVG_HALF_LIFE);
|
||||
}
|
||||
if (credit_assigned_time) {
|
||||
double deltat = now - credit_assigned_time;
|
||||
// Add (credit)/(number of days to return result) to credit,
|
||||
// which is the average number of cobblestones per day
|
||||
//
|
||||
avg += credit/(deltat/SECONDS_IN_DAY);
|
||||
double diff = now - avg_time;
|
||||
double diff_days = diff/SECONDS_IN_DAY;
|
||||
double weight = exp(-diff*LOG2/AVG_HALF_LIFE);
|
||||
avg *= weight;
|
||||
avg += (1-weight)*(credit/diff_days);
|
||||
} else {
|
||||
double dd = (now - credit_assigned_time)/SECONDS_IN_DAY;
|
||||
avg = credit/dd;
|
||||
}
|
||||
avg_time = now;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue