- added comment index for performance sake

- improved comment module - code revision
- improved backend module - moreover headlines now work
- (automatically) stripped tabs and trailing whitespaces from
  Jeroen's theme.
3-00
Dries Buytaert 2001-02-27 07:45:03 +00:00
parent 3364e84317
commit 4d31d27ff0
7 changed files with 37 additions and 55 deletions

View File

@ -24,7 +24,7 @@ drupal 1.xx, xx/xx/2001
* improved diary module: * improved diary module:
+ diary can be deleted + diary can be deleted
* improved headline module: * improved headline module:
+ improved parser to support RDF/RSS/XML backend + improved parser to support more "generic" RDF/RSS/XML backend
* improved module module * improved module module
* improved watchdog module * improved watchdog module
* added CREDITS file * added CREDITS file

View File

@ -67,6 +67,7 @@ CREATE TABLE comments (
timestamp int(11) DEFAULT '0' NOT NULL, timestamp int(11) DEFAULT '0' NOT NULL,
score int(6) DEFAULT '0' NOT NULL, score int(6) DEFAULT '0' NOT NULL,
votes int(6) DEFAULT '0' NOT NULL, votes int(6) DEFAULT '0' NOT NULL,
INDEX lid_link (lid, link),
PRIMARY KEY (cid) PRIMARY KEY (cid)
); );

View File

@ -51,24 +51,17 @@ class backend {
if ($this->file) { if ($this->file) {
// Decode URL: // Decode URL:
$url = parse_url($this->file); $url = parse_url($this->file);
$host = $url[host];
$port = $url[port] ? $url[port] : 80;
$path = $url[path];
// print "<PRE><B>Debug:</B> $url - $host - $port - $path</PRE>";
// Retrieve data from website: // Retrieve data from website:
$fp = fsockopen($host, $port, &$errno, &$errstr, $timout); $fp = fsockopen($url[host], ($url[port] ? $url[port] : 80), &$errno, &$errstr, $timout);
if ($fp) { if ($fp) {
// Request data via URL: // Request data via URL:
fputs($fp, "GET $path HTTP/1.0\nUser-Agent: $site_name\nHost: $host\nAccept: */*\n\n"); fputs($fp, "GET $url[path]?$url[query] HTTP/1.0\nUser-Agent: $site_name\nHost: $url[host]\nAccept: */*\n\n");
// Read data from socket: // Read data from socket:
while(!feof($fp)) $data .= fgets($fp, 128); while(!feof($fp)) $data .= fgets($fp, 128);
// print "<PRE>$data</PRE><HR>";
if (strstr($data, "200 OK")) { if (strstr($data, "200 OK")) {
// Remove existing entries: // Remove existing entries:

View File

@ -26,24 +26,16 @@ function comment_edit($id) {
$output .= "<FORM ACTION=\"admin.php?mod=comment&op=save&id=$id\" METHOD=\"post\">\n"; $output .= "<FORM ACTION=\"admin.php?mod=comment&op=save&id=$id\" METHOD=\"post\">\n";
$output .= "<P>\n"; $output .= "<B>Author:</B><BR>\n";
$output .= " <B>Author:</B><BR>\n"; $output .= format_username($comment->userid) ."<P>\n";
$output .= " ". format_username($comment->userid) ."\n";
$output .= "</P>\n";
$output .= "<P>\n"; $output .= "<B>Subject:</B><BR>\n";
$output .= " <B>Subject:</B><BR>\n"; $output .= "<INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" VALUE=\"". check_textfield($comment->subject) ."\"><P>\n";
$output .= " <INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" VALUE=\"". check_textfield($comment->subject) ."\">\n";
$output .= "</P>\n";
$output .= "<P>\n";
$output .= "<B>Comment:</B><BR>\n"; $output .= "<B>Comment:</B><BR>\n";
$output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"comment\">". check_textarea($comment->comment) ."</TEXTAREA>\n"; $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"comment\">". check_textarea($comment->comment) ."</TEXTAREA><P>\n";
$output .= "</P>\n";
$output .= "<P>\n"; $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save comment\">\n";
$output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save comment\">\n";
$output .= "</P>\n";
$output .= "</FORM>\n"; $output .= "</FORM>\n";
print $output; print $output;
@ -51,7 +43,7 @@ function comment_edit($id) {
function comment_save($id, $subject, $comment) { function comment_save($id, $subject, $comment) {
db_query("UPDATE comments SET subject = '". check_input($subject) ."', comment = '". check_input($comment) ."' WHERE cid = $id"); db_query("UPDATE comments SET subject = '". check_input($subject) ."', comment = '". check_input($comment) ."' WHERE cid = $id");
watchdog("message", "comment: modified `$subject'"); watchdog("message", "comment: modified '$subject'");
} }
function comment_display($order = "date") { function comment_display($order = "date") {
@ -105,7 +97,7 @@ function comment_admin() {
break; break;
case "Save comment": case "Save comment":
comment_save($id, $subject, $comment); comment_save($id, $subject, $comment);
comment_edit($id); comment_display();
break; break;
case "Update": case "Update":
comment_display($order); comment_display($order);

View File

@ -26,24 +26,16 @@ function comment_edit($id) {
$output .= "<FORM ACTION=\"admin.php?mod=comment&op=save&id=$id\" METHOD=\"post\">\n"; $output .= "<FORM ACTION=\"admin.php?mod=comment&op=save&id=$id\" METHOD=\"post\">\n";
$output .= "<P>\n"; $output .= "<B>Author:</B><BR>\n";
$output .= " <B>Author:</B><BR>\n"; $output .= format_username($comment->userid) ."<P>\n";
$output .= " ". format_username($comment->userid) ."\n";
$output .= "</P>\n";
$output .= "<P>\n"; $output .= "<B>Subject:</B><BR>\n";
$output .= " <B>Subject:</B><BR>\n"; $output .= "<INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" VALUE=\"". check_textfield($comment->subject) ."\"><P>\n";
$output .= " <INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" VALUE=\"". check_textfield($comment->subject) ."\">\n";
$output .= "</P>\n";
$output .= "<P>\n";
$output .= "<B>Comment:</B><BR>\n"; $output .= "<B>Comment:</B><BR>\n";
$output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"comment\">". check_textarea($comment->comment) ."</TEXTAREA>\n"; $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"comment\">". check_textarea($comment->comment) ."</TEXTAREA><P>\n";
$output .= "</P>\n";
$output .= "<P>\n"; $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save comment\">\n";
$output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save comment\">\n";
$output .= "</P>\n";
$output .= "</FORM>\n"; $output .= "</FORM>\n";
print $output; print $output;
@ -51,7 +43,7 @@ function comment_edit($id) {
function comment_save($id, $subject, $comment) { function comment_save($id, $subject, $comment) {
db_query("UPDATE comments SET subject = '". check_input($subject) ."', comment = '". check_input($comment) ."' WHERE cid = $id"); db_query("UPDATE comments SET subject = '". check_input($subject) ."', comment = '". check_input($comment) ."' WHERE cid = $id");
watchdog("message", "comment: modified `$subject'"); watchdog("message", "comment: modified '$subject'");
} }
function comment_display($order = "date") { function comment_display($order = "date") {
@ -105,7 +97,7 @@ function comment_admin() {
break; break;
case "Save comment": case "Save comment":
comment_save($id, $subject, $comment); comment_save($id, $subject, $comment);
comment_edit($id); comment_display();
break; break;
case "Update": case "Update":
comment_display($order); comment_display($order);

View File

@ -83,11 +83,11 @@
<TR> <TR>
<TD></TD> <TD></TD>
<TD> <TD>
<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="100%"> <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="100%">
<TR> <TR>
<TD> <TD>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%"> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">
<TR> <TR>
<TD ALIGN="left" BACKGROUND="themes/jeroen/images/menutitle.gif" NOWRAP> <TD ALIGN="left" BACKGROUND="themes/jeroen/images/menutitle.gif" NOWRAP>
&nbsp; &nbsp;
<FONT COLOR="<? echo $this->fgc2; ?>"> <FONT COLOR="<? echo $this->fgc2; ?>">
@ -137,10 +137,10 @@
</TR> </TR>
</TABLE> </TABLE>
</TD> </TD>
</TR> </TR>
</TABLE> </TABLE>
</TD> </TD>
</TR> </TR>
</TABLE> </TABLE>
<BR> <BR>
<? <?
@ -250,10 +250,10 @@
echo " <TR>"; echo " <TR>";
echo " <TD>"; echo " <TD>";
echo " <TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"0\" BGCOLOR=\"#000000\" WIDTH=\"100%\">"; echo " <TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"0\" BGCOLOR=\"#000000\" WIDTH=\"100%\">";
echo " <TR>"; echo " <TR>";
echo " <TD>"; echo " <TD>";
echo " <TABLE BACKGROUND=\"themes/jeroen/images/menutitle.gif\" BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"0\" WIDTH=\"100%\">"; echo " <TABLE BACKGROUND=\"themes/jeroen/images/menutitle.gif\" BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"0\" WIDTH=\"100%\">";
echo " <TR>"; echo " <TR>";
echo " </TR>"; echo " </TR>";
echo " <TD>"; echo " <TD>";
echo " <TABLE BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"2\"WIDTH=\"100%\">"; echo " <TABLE BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"2\"WIDTH=\"100%\">";

View File

@ -1,4 +1,8 @@
# 26/02/2001: performance optimization
ALTER TABLE comments ADD INDEX lid_link (lid, link);
# 19/02/2001: internationalization / translation # 19/02/2001: internationalization / translation
alter table users add language varchar(2) DEFAULT '0' NOT NULL;
CREATE TABLE locales ( CREATE TABLE locales (
id int(11) DEFAULT '0' NOT NULL auto_increment, id int(11) DEFAULT '0' NOT NULL auto_increment,
location varchar(128) DEFAULT '' NOT NULL, location varchar(128) DEFAULT '' NOT NULL,