Commit d95499bf authored by Dries's avatar Dries

- Bugfix: small Xtemplate fixes.  Patch by Ax.  (Slightly modified.)

- Bugfix: block patch fix.  Patch by Gerhard.

- Bugfix: fixed broken URL in ping.  Patch by Gerhard.

  (This should fix the problems shown on http://www.blo.gs/info.php?id=1515.)

- Improvement: added better password generator.  Patch #1 by Al.  Fixes bug
  #1935.

- Improvement: performance improvement to the blog module.  Patch by Marco.
parent c0330f16
......@@ -192,7 +192,7 @@ function theme_blocks($region) {
$result = db_query("SELECT * FROM blocks WHERE (status = '1' OR custom = '1') ". ($region != "all" ? "AND region = %d " : "") ."ORDER BY weight, module", $region == "left" ? 0 : 1);
while ($result && ($block = db_fetch_object($result))) {
if ((($block->status && (!$user->uid || !$block->custom)) || ($block->custom && $user->block[$block->module][$block->delta])) && (!$block->path || preg_match('/'. str_replace('/', '\/', $block->path) .'/', request_uri()))) {
if ((($block->status && (!$user->uid || !$block->custom)) || ($block->custom && $user->block[$block->module][$block->delta])) && (!$block->path || preg_match(str_replace('/', '\/', $block->path), str_replace("?q=", "", request_uri())))) {
$block_data = module_invoke($block->module, "block", "view", $block->delta);
if ($block_data["content"]) {
theme("block", $block_data["subject"], $block_data["content"], $region);
......
......@@ -249,7 +249,7 @@ function blog_block($op = "list", $delta = 0) {
}
else {
if (user_access("access content")) {
$block["content"] = node_title_list(db_query_range("SELECT u.uid, u.name, n.created, n.title, n.nid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 10));
$block["content"] = node_title_list(db_query_range("SELECT n.title, n.nid FROM node n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 10));
$block["content"] .= "<div align=\"right\" id=\"blog_more\">". l(t("more"), "blog", array("title" => t("Read the latest blog entries."))) ."</div>";
$block["subject"] = t("Blogs");
}
......
......@@ -249,7 +249,7 @@ function blog_block($op = "list", $delta = 0) {
}
else {
if (user_access("access content")) {
$block["content"] = node_title_list(db_query_range("SELECT u.uid, u.name, n.created, n.title, n.nid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 10));
$block["content"] = node_title_list(db_query_range("SELECT n.title, n.nid FROM node n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 10));
$block["content"] .= "<div align=\"right\" id=\"blog_more\">". l(t("more"), "blog", array("title" => t("Read the latest blog entries."))) ."</div>";
$block["subject"] = t("Blogs");
}
......
......@@ -47,14 +47,9 @@ function node_system($field){
** Returns an HTML list suitable as content for a block.
*/
function node_title_list($result, $title = NULL) {
// no queries if site is in distress
if (module_exist("statistics") && throttle_status() > 3) {
return;
}
while ($node = db_fetch_object($result)) {
$number = module_invoke("comment", "num_all", $node->nid);
$items[] = l($node->title, "node/view/$node->nid", array("title" => t("Comments: %number", array("%number" => $number))));
$items[] = l($node->title, "node/view/$node->nid", array("title" => format_plural($number, "%count comment", "%count comments")));
}
return theme("theme_node_list", $items, $title);
......
......@@ -47,14 +47,9 @@ function node_system($field){
** Returns an HTML list suitable as content for a block.
*/
function node_title_list($result, $title = NULL) {
// no queries if site is in distress
if (module_exist("statistics") && throttle_status() > 3) {
return;
}
while ($node = db_fetch_object($result)) {
$number = module_invoke("comment", "num_all", $node->nid);
$items[] = l($node->title, "node/view/$node->nid", array("title" => t("Comments: %number", array("%number" => $number))));
$items[] = l($node->title, "node/view/$node->nid", array("title" => format_plural($number, "%count comment", "%count comments")));
}
return theme("theme_node_list", $items, $title);
......
......@@ -34,7 +34,7 @@ function _ping_notify($name, $url) {
}
function ping_ping($name = "", $url = "") {
$feed = $url . url("node/feed");
$feed = url("node/feed");
$client = new xmlrpc_client("/RPC2", "rpc.weblogs.com", 80);
......
......@@ -34,7 +34,7 @@ function _ping_notify($name, $url) {
}
function ping_ping($name = "", $url = "") {
$feed = $url . url("node/feed");
$feed = url("node/feed");
$client = new xmlrpc_client("/RPC2", "rpc.weblogs.com", 80);
......
......@@ -6,7 +6,7 @@
function user_system($field){
$system["description"] = t("Enables the user registration and login system.");
$system["admin_help"] = t("In order to use the full power of Drupal a visitor must sign up for an account. This page lets you setup how a user signs up, logs out, what password \"words\" the system uses, the guidelines from the system about user subscriptions, and the e-mail's the system will send to the user.");
$system["admin_help"] = t("In order to use the full power of Drupal a visitor must sign up for an account. This page lets you setup how a user signs up, logs out, the guidelines from the system about user subscriptions, and the e-mails the system will send to the user.");
return $system[$field];
}
......@@ -194,16 +194,35 @@ function user_validate_authmap($account, $authname, $module) {
}
}
function user_password($min_length = 6) {
function user_password($length = 10) {
/*
** Generate a human-readable password:
** Generate a random alphanumeric password.
*/
// This variable contains the list of allowable characters for the
// password. Note that the number 0 and the letter 'O' have been
// removed to avoid confusion between the two. The same is true
// of 'I' and 1.
$allowable_characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
// We see how many characters are in the allowable list:
$len = strlen($allowable_characters);
// Seed the random number generator with the microtime stamp:
mt_srand((double)microtime() * 1000000);
$words = explode(",", variable_get("user_password", "foo,bar,guy,neo,tux,moo,sun,asm,dot,god,axe,geek,nerd,fish,hack,star,mice,warp,moon,hero,cola,girl,fish,java,perl,boss,dark,sith,jedi,drop,mojo"));
while (strlen($password) < $min_length) $password .= trim($words[mt_rand(0, count($words))]);
return $password;
// Declare the password as a blank string:
$pass = "";
// Loop the number of times specified by $length:
for ($i = 0; $i < $length; $i++) {
// Each iteration, pick a random character from the
// allowable string and append it to the password:
$pass .= $allowable_characters[mt_rand(0, $len - 1)];
}
return $pass;
}
function user_access($string) {
......@@ -1172,8 +1191,6 @@ function _user_mail_text($message) {
function user_settings() {
$output .= form_select(t("Public registrations"), "user_register", variable_get("user_register", 1), array(t("Only site administrators can create new user accounts."), t("Visitors can create accounts and no administrator approval is required."), t("Visitors can create accounts but administrator approval is required.")));
$output .= form_textfield(t("Password words"), "user_password", variable_get("user_password", "foo,bar,guy,neo,tux,moo,sun,asm,dot,god,axe,geek,nerd,fish,hack,star,mice,warp,moon,hero,cola,girl,fish,java,perl,boss,dark,sith,jedi,drop,mojo"), 55, 256, t("A comma separated list of short words that can be concatenated to generate human-readable passwords."));
$output .= form_select(t("Remember authenticated users"), "user_remember", variable_get("user_remember", 0), array(t("Let the user decide whether he should be logged out when leaving the site."), t("Authenticated users are not logged out upon leaving the site."), t("Authenticated users are logged out upon leaving the site.")));
$output .= form_textarea(t("User registration guidelines"), "user_registration_help", variable_get("user_registration_help", ""), 70, 4, t("This text is displayed at the top of the user registration form. It's useful for helping or instructing your users."));
......
......@@ -6,7 +6,7 @@
function user_system($field){
$system["description"] = t("Enables the user registration and login system.");
$system["admin_help"] = t("In order to use the full power of Drupal a visitor must sign up for an account. This page lets you setup how a user signs up, logs out, what password \"words\" the system uses, the guidelines from the system about user subscriptions, and the e-mail's the system will send to the user.");
$system["admin_help"] = t("In order to use the full power of Drupal a visitor must sign up for an account. This page lets you setup how a user signs up, logs out, the guidelines from the system about user subscriptions, and the e-mails the system will send to the user.");
return $system[$field];
}
......@@ -194,16 +194,35 @@ function user_validate_authmap($account, $authname, $module) {
}
}
function user_password($min_length = 6) {
function user_password($length = 10) {
/*
** Generate a human-readable password:
** Generate a random alphanumeric password.
*/
// This variable contains the list of allowable characters for the
// password. Note that the number 0 and the letter 'O' have been
// removed to avoid confusion between the two. The same is true
// of 'I' and 1.
$allowable_characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
// We see how many characters are in the allowable list:
$len = strlen($allowable_characters);
// Seed the random number generator with the microtime stamp:
mt_srand((double)microtime() * 1000000);
$words = explode(",", variable_get("user_password", "foo,bar,guy,neo,tux,moo,sun,asm,dot,god,axe,geek,nerd,fish,hack,star,mice,warp,moon,hero,cola,girl,fish,java,perl,boss,dark,sith,jedi,drop,mojo"));
while (strlen($password) < $min_length) $password .= trim($words[mt_rand(0, count($words))]);
return $password;
// Declare the password as a blank string:
$pass = "";
// Loop the number of times specified by $length:
for ($i = 0; $i < $length; $i++) {
// Each iteration, pick a random character from the
// allowable string and append it to the password:
$pass .= $allowable_characters[mt_rand(0, $len - 1)];
}
return $pass;
}
function user_access($string) {
......@@ -1172,8 +1191,6 @@ function _user_mail_text($message) {
function user_settings() {
$output .= form_select(t("Public registrations"), "user_register", variable_get("user_register", 1), array(t("Only site administrators can create new user accounts."), t("Visitors can create accounts and no administrator approval is required."), t("Visitors can create accounts but administrator approval is required.")));
$output .= form_textfield(t("Password words"), "user_password", variable_get("user_password", "foo,bar,guy,neo,tux,moo,sun,asm,dot,god,axe,geek,nerd,fish,hack,star,mice,warp,moon,hero,cola,girl,fish,java,perl,boss,dark,sith,jedi,drop,mojo"), 55, 256, t("A comma separated list of short words that can be concatenated to generate human-readable passwords."));
$output .= form_select(t("Remember authenticated users"), "user_remember", variable_get("user_remember", 0), array(t("Let the user decide whether he should be logged out when leaving the site."), t("Authenticated users are not logged out upon leaving the site."), t("Authenticated users are logged out upon leaving the site.")));
$output .= form_textarea(t("User registration guidelines"), "user_registration_help", variable_get("user_registration_help", ""), 70, 4, t("This text is displayed at the top of the user registration form. It's useful for helping or instructing your users."));
......
......@@ -80,7 +80,6 @@ img {
#search .form-text {
width: 8em;
height: 1.4em;
margin-left: 1em;
padding: 0 0.5em 0 0.5em;
margin: 0 0 0.5em 0;
}
......@@ -102,7 +101,7 @@ img {
#message, #main .node .content, .comment .content {
line-height: 1.4;
}
#sidebar {
#sidebar-left, #sidebar-right {
background-color: #ddd;
width: 16em;
padding: 1em;
......@@ -172,9 +171,6 @@ table {
float: right;
color: red;
}
.block .content, .box .content {
font-size: 0.9em/1.1em;
}
#tracker th {
text-align: left;
border-bottom: 1px solid #ddd;
......
......@@ -33,7 +33,7 @@
<table border="0" cellpadding="0" cellspacing="0" class="header">
<tr>
<!-- BEGIN: blocks -->
<td valign="top" id="sidebar">
<td valign="top" id="sidebar-left">
{blocks}
</td>
<!-- END: blocks -->
......@@ -91,7 +91,7 @@
</div><!-- main -->
</td>
<!-- BEGIN: blocks -->
<td valign="top" id="sidebar">
<td valign="top" id="sidebar-right">
{blocks}
</td>
<!-- END: blocks -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment