Commit d659fedb authored by Dries's avatar Dries

- Removed the path_uri() function in favor of the $base_url variable and
  fixes a handful of bugs introduced by the clean URL patch.
parent d5fe0cfe
......@@ -98,19 +98,6 @@ function object2array($node) {
return $array;
}
function path_uri($brief = 0) {
global $HTTP_HOST, $PHP_SELF;
$uri = $PHP_SELF;
$path = $HTTP_HOST . substr($uri, 0, strrpos($uri, "/")) ."/";
if (!$brief) {
$path = "http://". $path;
}
return $path;
}
function request_uri() {
// since request_uri() is only available on apache, we generate equivalent using other environment vars.
......@@ -786,18 +773,18 @@ function url($url = NULL, $query = NULL) {
if (variable_get("clean_url", "0") == "0") {
if (isset($url)) {
if (isset($query)) {
return "?q=$url&$query";
return "$base_url/?q=$url&$query";
}
else {
return "?q=$url";
return "$base_url/?q=$url";
}
}
else {
if (isset($query)) {
return "?$query";
return "$base_url/?$query";
}
else {
return "";
return "$base_url/";
}
}
}
......@@ -815,7 +802,7 @@ function url($url = NULL, $query = NULL) {
return "$base_url/?$query";
}
else {
return "$base_url";
return "$base_url/";
}
}
}
......
......@@ -53,7 +53,7 @@ function blog_head($main = 0) {
if ($mod == "blog" && $id) {
$account = user_load(array("uid" => $id));
$output[] = "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS - ". $account->name. "'s blog\" href=\"". path_uri() . url("blog/view/$id") ."\" />";
$output[] = "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS - ". $account->name. "'s blog\" href=\"". url("blog/view/$id") ."\" />";
}
return $output ? $output : array();
......@@ -132,7 +132,7 @@ function blog_feed_user($uid = 0) {
$result = db_query("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = '%d' AND n.status = 1 ORDER BY n.nid DESC LIMIT 15", $uid);
$channel["title"] = $account->name. "'s blog";
$channel["link"] = path_uri() . url("blog/view/$uid");
$channel["link"] = url("blog/view/$uid");
$channel["description"] = $term->description;
node_feed($result, $channel);
}
......@@ -140,7 +140,7 @@ function blog_feed_user($uid = 0) {
function blog_feed_last() {
$result = db_query("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid 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 LIMIT 15");
$channel["title"] = variable_get("site_name", "drupal") ." blogs";
$channel["link"] = path_uri() . url("blog/view");
$channel["link"] = url("blog/view");
$channel["description"] = $term->description;
node_feed($result, $channel);
}
......
......@@ -53,7 +53,7 @@ function blog_head($main = 0) {
if ($mod == "blog" && $id) {
$account = user_load(array("uid" => $id));
$output[] = "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS - ". $account->name. "'s blog\" href=\"". path_uri() . url("blog/view/$id") ."\" />";
$output[] = "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS - ". $account->name. "'s blog\" href=\"". url("blog/view/$id") ."\" />";
}
return $output ? $output : array();
......@@ -132,7 +132,7 @@ function blog_feed_user($uid = 0) {
$result = db_query("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = '%d' AND n.status = 1 ORDER BY n.nid DESC LIMIT 15", $uid);
$channel["title"] = $account->name. "'s blog";
$channel["link"] = path_uri() . url("blog/view/$uid");
$channel["link"] = url("blog/view/$uid");
$channel["description"] = $term->description;
node_feed($result, $channel);
}
......@@ -140,7 +140,7 @@ function blog_feed_user($uid = 0) {
function blog_feed_last() {
$result = db_query("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid 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 LIMIT 15");
$channel["title"] = variable_get("site_name", "drupal") ." blogs";
$channel["link"] = path_uri() . url("blog/view");
$channel["link"] = url("blog/view");
$channel["description"] = $term->description;
node_feed($result, $channel);
}
......
......@@ -223,10 +223,7 @@ function bloggerapi_user_blogs() {
global $user;
if ($user->uid) {
$struct = new xmlrpcval(array("url" => new xmlrpcval(path_uri() . url("blog/view". urlencode($user->uid))),
"blogid" => new xmlrpcval($user->uid),
"blogName" => new xmlrpcval($user->name . "'s blog at ". variable_get("site_name", "drupal"))
),"struct");
$struct = new xmlrpcval(array("url" => new xmlrpcval(url("blog/view". urlencode($user->uid))), "blogid" => new xmlrpcval($user->uid), "blogName" => new xmlrpcval($user->name . "'s blog at ". variable_get("site_name", "drupal"))),"struct");
return new xmlrpcval(array($struct), "array");
}
else {
......@@ -240,7 +237,7 @@ function bloggerapi_user_info() {
if ($user->uid) {
return new xmlrpcval(array("nickname" => new xmlrpcval($user->name, "string"),
"userid" => new xmlrpcval($user->id, "string"),
"url" => new xmlrpcval(path_uri() . url("blog/view/". urlencode($user->uid)), "string"),
"url" => new xmlrpcval(url("blog/view/". urlencode($user->uid)), "string"),
"email" => new xmlrpcval($user->mail, "string"),
"lastname" => new xmlrpcval(substr($user->name, strrpos($user->name," ")+1), "string"),
"firstname" => new xmlrpcval(substr($user->name, 0, strrpos($user->name," ")), "string"),
......
......@@ -99,12 +99,13 @@ function drupal_xmlrpc() {
}
function drupal_notify($server) {
global $base_url;
$url = parse_url($server);
$client = new xmlrpc_client($url["path"], $url["host"], 80);
$message = new xmlrpcmsg("drupal.site.ping", array(new xmlrpcval(path_uri(), "string"), new xmlrpcval(variable_get("site_name", ""), "string"), new xmlrpcval(variable_get("site_mail", ""), "string"), new xmlrpcval(variable_get("site_slogan", ""), "string"), new xmlrpcval(variable_get("site_mission", ""), "string")));
$message = new xmlrpcmsg("drupal.site.ping", array(new xmlrpcval($base_url, "string"), new xmlrpcval(variable_get("site_name", ""), "string"), new xmlrpcval(variable_get("site_mail", ""), "string"), new xmlrpcval(variable_get("site_slogan", ""), "string"), new xmlrpcval(variable_get("site_mission", ""), "string")));
$result = $client->send($message, 5);
......@@ -185,11 +186,11 @@ function drupal_user($type, $edit, $user) {
$output .= form_item(t("$name ID"), $result);
}
else {
// TODO: use a variation of path_uri() instead of $HTTP_HOST below
// TODO: use a variation of $base_url instead of $HTTP_HOST below
$output .= form_item(t("$name ID"), "$user->name@$HTTP_HOST");
}
return $output;
}
}
?>
\ No newline at end of file
?>
......@@ -99,12 +99,13 @@ function drupal_xmlrpc() {
}
function drupal_notify($server) {
global $base_url;
$url = parse_url($server);
$client = new xmlrpc_client($url["path"], $url["host"], 80);
$message = new xmlrpcmsg("drupal.site.ping", array(new xmlrpcval(path_uri(), "string"), new xmlrpcval(variable_get("site_name", ""), "string"), new xmlrpcval(variable_get("site_mail", ""), "string"), new xmlrpcval(variable_get("site_slogan", ""), "string"), new xmlrpcval(variable_get("site_mission", ""), "string")));
$message = new xmlrpcmsg("drupal.site.ping", array(new xmlrpcval($base_url, "string"), new xmlrpcval(variable_get("site_name", ""), "string"), new xmlrpcval(variable_get("site_mail", ""), "string"), new xmlrpcval(variable_get("site_slogan", ""), "string"), new xmlrpcval(variable_get("site_mission", ""), "string")));
$result = $client->send($message, 5);
......@@ -185,11 +186,11 @@ function drupal_user($type, $edit, $user) {
$output .= form_item(t("$name ID"), $result);
}
else {
// TODO: use a variation of path_uri() instead of $HTTP_HOST below
// TODO: use a variation of $base_url instead of $HTTP_HOST below
$output .= form_item(t("$name ID"), "$user->name@$HTTP_HOST");
}
return $output;
}
}
?>
\ No newline at end of file
?>
......@@ -705,6 +705,8 @@ function node_block($op = "list", $delta = 0) {
}
function node_feed($nodes = 0, $channel = array()) {
global $base_url;
/*
** A generic function for generating RSS feeds from a set of nodes.
** - $nodes should be an object as returned by db_query() which contains
......@@ -719,7 +721,7 @@ function node_feed($nodes = 0, $channel = array()) {
while ($node = db_fetch_object($nodes)) {
$item = node_load(array("nid" => $node->nid));
$link = path_uri() . url("node/view/$item->nid");
$link = url("node/view/$item->nid");
$items .= format_rss_item($item->title, $link, $item->teaser);
}
......@@ -728,7 +730,7 @@ function node_feed($nodes = 0, $channel = array()) {
// NOTE: &eacute; - for example - is the correct ISO-8859-1 translation of (e acute) but apparently XML parsers don't (have to) understand it. To solve this problem, we use a DTD that defines commonly used entity such as &eacute;.
if (!$channel["version"]) $channel["version"] = "0.91";
if (!$channel["title"]) $channel["title"] = variable_get("site_name", "drupal") ." - ". variable_get("site_slogan", "");
if (!$channel["link"]) $channel["link"] = path_uri();
if (!$channel["link"]) $channel["link"] = $base_url;
if (!$channel["description"]) $channel["description"] = variable_get("site_mission", "");
if (!$channel["language"]) $channel["language"] = "en";
$output .= "<rss version=\"". $channel["version"] . "\">\n";
......
......@@ -705,6 +705,8 @@ function node_block($op = "list", $delta = 0) {
}
function node_feed($nodes = 0, $channel = array()) {
global $base_url;
/*
** A generic function for generating RSS feeds from a set of nodes.
** - $nodes should be an object as returned by db_query() which contains
......@@ -719,7 +721,7 @@ function node_feed($nodes = 0, $channel = array()) {
while ($node = db_fetch_object($nodes)) {
$item = node_load(array("nid" => $node->nid));
$link = path_uri() . url("node/view/$item->nid");
$link = url("node/view/$item->nid");
$items .= format_rss_item($item->title, $link, $item->teaser);
}
......@@ -728,7 +730,7 @@ function node_feed($nodes = 0, $channel = array()) {
// NOTE: &eacute; - for example - is the correct ISO-8859-1 translation of (e acute) but apparently XML parsers don't (have to) understand it. To solve this problem, we use a DTD that defines commonly used entity such as &eacute;.
if (!$channel["version"]) $channel["version"] = "0.91";
if (!$channel["title"]) $channel["title"] = variable_get("site_name", "drupal") ." - ". variable_get("site_slogan", "");
if (!$channel["link"]) $channel["link"] = path_uri();
if (!$channel["link"]) $channel["link"] = $base_url;
if (!$channel["description"]) $channel["description"] = variable_get("site_mission", "");
if (!$channel["language"]) $channel["language"] = "en";
$output .= "<rss version=\"". $channel["version"] . "\">\n";
......
......@@ -18,9 +18,11 @@ function ping_system($field){
}
function ping_cron() {
global $base_url;
if (variable_get("site_name", 0) && variable_get("site_slogan", 0)) {
if (db_num_rows(db_query("SELECT nid FROM node WHERE status = 1 AND moderate = 0 AND (created > '". variable_get("ping_cron_last", time()) ."' OR changed > '". variable_get("ping_cron_last", time()) ."')"), 1)) {
_ping_notify(variable_get("site_name", "") ." - ". variable_get("site_slogan", ""), path_uri());
_ping_notify(variable_get("site_name", "") ." - ". variable_get("site_slogan", ""), $base_url);
}
variable_set("ping_cron_last", time());
......
......@@ -18,9 +18,11 @@ function ping_system($field){
}
function ping_cron() {
global $base_url;
if (variable_get("site_name", 0) && variable_get("site_slogan", 0)) {
if (db_num_rows(db_query("SELECT nid FROM node WHERE status = 1 AND moderate = 0 AND (created > '". variable_get("ping_cron_last", time()) ."' OR changed > '". variable_get("ping_cron_last", time()) ."')"), 1)) {
_ping_notify(variable_get("site_name", "") ." - ". variable_get("site_slogan", ""), path_uri());
_ping_notify(variable_get("site_name", "") ." - ". variable_get("site_slogan", ""), $base_url);
}
variable_set("ping_cron_last", time());
......
......@@ -20,11 +20,13 @@ function system_help_cache() {
}
function system_help_cron() {
global $base_url;
$output .= "<p>Some settings require a <i>cron</i> or <i>crontab</i>. Cron, which stands for chronograph, is a periodic command scheduler: it executes commands at intervals specified in seconds. It can be used to control the execution of daily, weekly and monthly jobs (or anything with a period of <i>n</i> seconds). Automating tasks is one of the best ways to keep a system running smoothly, and if most of your administration does not require your direct involvement, cron is an ideal solution.</p>";
$output .= "<p>Whenever <a href=\"". path_uri() ."cron.php\">". path_uri() ."cron.php</a> is accessed, cron will run: it checks for the jobs cron controls, and their periods in seconds. If a certain task wasn't executed in the last n seconds, where n is the period of that job, it will be executed. When all the executed commands terminate, cron is done.</p>";
$output .= "<p>The recommended way to setup your cron system is to setup a Unix/Linux crontab that frequently visits <a href=\"". path_uri() ."cron.php\">". path_uri() ."cron.php</a>. Note that cron does not guarantee the commands will be executed at the specified interval. However, Drupal will try his best and run the crons as close to the specified intervals as possible. The more you visit cron.php, the more accurate cron will be.</p>";
$output .= "<p>If your hosting company does not allow you to setup crontabs, you can always ask someone else to setup a crontab for you. After all, virtually any Unix/Linux machine with access to the internet can setup a crontab to frequently visit <a href=\"". path_uri() ."cron.php\">". path_uri() ."cron.php</a>.</p>";
$output .= "<p>For the Unix/Linux crontab itself, use a browser like <i>lynx</i> or <i>wget</i> but make sure the process terminates: either use <code>/usr/bin/lynx -source " . path_uri() . "cron.php</code> or <code>/usr/bin/wget -O /dev/null " . path_uri() ."cron.php</code>. Take a look at the example scripts in the <code>scripts</code>-directory and make sure to adjust them to your needs. A good crontab-line to run the cron-script once every hour would be: <pre> 00 * * * * /home/www/drupal/scripts/cron-lynx.sh</pre>Note that it is essential to access <code>cron.php</code> using a browser; don't run it using command line PHP and avoid using <code>localhost</code> or <code>127.0.0.1</code>, or some features won't work as expected. For all the environment variables to be correct; use a browser to access <code>cron.php</code> on a publicly accessible domain.</p>";
$output .= "<p>Whenever <a href=\"$base_url/cron.php\">$base_url/cron.php</a> is accessed, cron will run: it checks for the jobs cron controls, and their periods in seconds. If a certain task wasn't executed in the last n seconds, where n is the period of that job, it will be executed. When all the executed commands terminate, cron is done.</p>";
$output .= "<p>The recommended way to setup your cron system is to setup a Unix/Linux crontab that frequently visits <a href=\"$base_url/cron.php\">$base_url/cron.php</a>. Note that cron does not guarantee the commands will be executed at the specified interval. However, Drupal will try his best and run the crons as close to the specified intervals as possible. The more you visit cron.php, the more accurate cron will be.</p>";
$output .= "<p>If your hosting company does not allow you to setup crontabs, you can always ask someone else to setup a crontab for you. After all, virtually any Unix/Linux machine with access to the internet can setup a crontab to frequently visit <a href=\"$base_url/cron.php\">$base_url/cron.php</a>.</p>";
$output .= "<p>For the Unix/Linux crontab itself, use a browser like <i>lynx</i> or <i>wget</i> but make sure the process terminates: either use <code>/usr/bin/lynx -source $base_url/cron.php</code> or <code>/usr/bin/wget -O /dev/null $base_url/cron.php</code>. Take a look at the example scripts in the <code>scripts</code>-directory and make sure to adjust them to your needs. A good crontab-line to run the cron-script once every hour would be: <pre> 00 * * * * /home/www/drupal/scripts/cron-lynx.sh</pre>Note that it is essential to access <code>cron.php</code> using a browser; don't run it using command line PHP and avoid using <code>localhost</code> or <code>127.0.0.1</code>, or some features won't work as expected. For all the environment variables to be correct; use a browser to access <code>cron.php</code> on a publicly accessible domain.</p>";
return $output;
}
......@@ -299,7 +301,7 @@ function system_listing($type, $directory, $required = array()) {
function system_init() {
global $HTTP_POST_VARS, $REQUEST_URI, $system_init_status;
session_register("system_init_status");
if (user_access("administer site configuration")) {
if (isset($HTTP_POST_VARS["op"]) && $HTTP_POST_VARS["op"] == t("Reset to defaults")) {
......@@ -317,7 +319,7 @@ function system_init() {
function system_admin() {
global $HTTP_POST_VARS, $system_init_status;
if (user_access("administer site configuration")) {
session_register("system_init_status");
print $system_init_status;
......
......@@ -20,11 +20,13 @@ function system_help_cache() {
}
function system_help_cron() {
global $base_url;
$output .= "<p>Some settings require a <i>cron</i> or <i>crontab</i>. Cron, which stands for chronograph, is a periodic command scheduler: it executes commands at intervals specified in seconds. It can be used to control the execution of daily, weekly and monthly jobs (or anything with a period of <i>n</i> seconds). Automating tasks is one of the best ways to keep a system running smoothly, and if most of your administration does not require your direct involvement, cron is an ideal solution.</p>";
$output .= "<p>Whenever <a href=\"". path_uri() ."cron.php\">". path_uri() ."cron.php</a> is accessed, cron will run: it checks for the jobs cron controls, and their periods in seconds. If a certain task wasn't executed in the last n seconds, where n is the period of that job, it will be executed. When all the executed commands terminate, cron is done.</p>";
$output .= "<p>The recommended way to setup your cron system is to setup a Unix/Linux crontab that frequently visits <a href=\"". path_uri() ."cron.php\">". path_uri() ."cron.php</a>. Note that cron does not guarantee the commands will be executed at the specified interval. However, Drupal will try his best and run the crons as close to the specified intervals as possible. The more you visit cron.php, the more accurate cron will be.</p>";
$output .= "<p>If your hosting company does not allow you to setup crontabs, you can always ask someone else to setup a crontab for you. After all, virtually any Unix/Linux machine with access to the internet can setup a crontab to frequently visit <a href=\"". path_uri() ."cron.php\">". path_uri() ."cron.php</a>.</p>";
$output .= "<p>For the Unix/Linux crontab itself, use a browser like <i>lynx</i> or <i>wget</i> but make sure the process terminates: either use <code>/usr/bin/lynx -source " . path_uri() . "cron.php</code> or <code>/usr/bin/wget -O /dev/null " . path_uri() ."cron.php</code>. Take a look at the example scripts in the <code>scripts</code>-directory and make sure to adjust them to your needs. A good crontab-line to run the cron-script once every hour would be: <pre> 00 * * * * /home/www/drupal/scripts/cron-lynx.sh</pre>Note that it is essential to access <code>cron.php</code> using a browser; don't run it using command line PHP and avoid using <code>localhost</code> or <code>127.0.0.1</code>, or some features won't work as expected. For all the environment variables to be correct; use a browser to access <code>cron.php</code> on a publicly accessible domain.</p>";
$output .= "<p>Whenever <a href=\"$base_url/cron.php\">$base_url/cron.php</a> is accessed, cron will run: it checks for the jobs cron controls, and their periods in seconds. If a certain task wasn't executed in the last n seconds, where n is the period of that job, it will be executed. When all the executed commands terminate, cron is done.</p>";
$output .= "<p>The recommended way to setup your cron system is to setup a Unix/Linux crontab that frequently visits <a href=\"$base_url/cron.php\">$base_url/cron.php</a>. Note that cron does not guarantee the commands will be executed at the specified interval. However, Drupal will try his best and run the crons as close to the specified intervals as possible. The more you visit cron.php, the more accurate cron will be.</p>";
$output .= "<p>If your hosting company does not allow you to setup crontabs, you can always ask someone else to setup a crontab for you. After all, virtually any Unix/Linux machine with access to the internet can setup a crontab to frequently visit <a href=\"$base_url/cron.php\">$base_url/cron.php</a>.</p>";
$output .= "<p>For the Unix/Linux crontab itself, use a browser like <i>lynx</i> or <i>wget</i> but make sure the process terminates: either use <code>/usr/bin/lynx -source $base_url/cron.php</code> or <code>/usr/bin/wget -O /dev/null $base_url/cron.php</code>. Take a look at the example scripts in the <code>scripts</code>-directory and make sure to adjust them to your needs. A good crontab-line to run the cron-script once every hour would be: <pre> 00 * * * * /home/www/drupal/scripts/cron-lynx.sh</pre>Note that it is essential to access <code>cron.php</code> using a browser; don't run it using command line PHP and avoid using <code>localhost</code> or <code>127.0.0.1</code>, or some features won't work as expected. For all the environment variables to be correct; use a browser to access <code>cron.php</code> on a publicly accessible domain.</p>";
return $output;
}
......@@ -299,7 +301,7 @@ function system_listing($type, $directory, $required = array()) {
function system_init() {
global $HTTP_POST_VARS, $REQUEST_URI, $system_init_status;
session_register("system_init_status");
if (user_access("administer site configuration")) {
if (isset($HTTP_POST_VARS["op"]) && $HTTP_POST_VARS["op"] == t("Reset to defaults")) {
......@@ -317,7 +319,7 @@ function system_init() {
function system_admin() {
global $HTTP_POST_VARS, $system_init_status;
if (user_access("administer site configuration")) {
session_register("system_init_status");
print $system_init_status;
......
......@@ -15,7 +15,7 @@ function taxonomy_feed($taxonomy) {
else {
$result = taxonomy_select_nodes($taxonomy, 0);
$term = taxonomy_get_term($taxonomy->tids[0]);
$channel["link"] = path_uri(). url("taxonomy/view/$taxonomy->operator/$taxonomy->str_tids");
$channel["link"] = url("taxonomy/view/$taxonomy->operator/$taxonomy->str_tids");
$channel["title"] = variable_get("site_name", "drupal") ." - ". $term->name;
$channel["description"] = $term->description;
node_feed($result, $channel);
......
......@@ -15,7 +15,7 @@ function taxonomy_feed($taxonomy) {
else {
$result = taxonomy_select_nodes($taxonomy, 0);
$term = taxonomy_get_term($taxonomy->tids[0]);
$channel["link"] = path_uri(). url("taxonomy/view/$taxonomy->operator/$taxonomy->str_tids");
$channel["link"] = url("taxonomy/view/$taxonomy->operator/$taxonomy->str_tids");
$channel["title"] = variable_get("site_name", "drupal") ." - ". $term->name;
$channel["description"] = $term->description;
node_feed($result, $channel);
......
......@@ -682,6 +682,8 @@ function user_logout() {
function user_pass($edit = array()) {
global $base_url;
if ($edit["name"]) {
$account = db_fetch_object(db_query("SELECT uid, name, mail FROM users WHERE name = '%s'", $edit["name"]));
if (!$account) $error = t("Sorry. The username <i>%s</i> is not recognized.", array("%s" => $edit["name"]));
......@@ -705,7 +707,7 @@ function user_pass($edit = array()) {
** Mail new password:
*/
$variables = array("%username" => $account->name, "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => path_uri(), "%uri_brief" => path_uri(1), "%mailto" => $account->mail, "%date" => format_date(time()));
$variables = array("%username" => $account->name, "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => $base_url, "%uri_brief" => substr($base_url, strlen("http://")), "%mailto" => $account->mail, "%date" => format_date(time()));
$subject = strtr(variable_get("user_mail_pass_subject", t("Replacement login information for %username at %site")), $variables);
$body = strtr(variable_get("user_mail_pass_body", t("%username,\n\nHere is your new password for %site. You may now login to %uri". url("user/login") ." using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %uri". url("user/edit") .".\n\nYour new %site membership also enables you to login to other Drupal powered websites (e.g. http://www.drop.org/) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), $variables);
$headers = "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from";
......@@ -741,7 +743,7 @@ function user_pass($edit = array()) {
}
function user_register($edit = array()) {
global $user;
global $user, $base_url;
/*
** If we are already logged on, go to the user page instead.
......@@ -804,7 +806,7 @@ function user_register($edit = array()) {
$account = user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "rid" => _user_authenticated_id(), "rating" => 0, "status" => (variable_get("user_register", 1) == 1 ? 1 : 0)), $data));
watchdog("user", "new user: '". $edit["name"] ."' &lt;". $edit["mail"] ."&gt;", l("edit user", "admin/user/edit/$account->uid"));
$variables = array("%username" => $edit["name"], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => path_uri(), "%uri_brief" => path_uri(1), "%mailto" => $edit["mail"], "%date" => format_date(time()));
$variables = array("%username" => $edit["name"], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => $base_url, "%uri_brief" => substr($base_url, strlen("http://")), "%mailto" => $edit["mail"], "%date" => format_date(time()));
//the first user may login immediately, and receives a customized welcome e-mail.
if ($account->uid == 1) {
......@@ -834,7 +836,7 @@ function user_register($edit = array()) {
$subject = strtr(variable_get("user_mail_welcome_subject", t("User account details for %username at %site")), $variables);
$body = strtr(variable_get("user_mail_welcome_body", t("%username,\n\nThank you for registering at %site. Your account will have to be approved by the site administrator. You may now login to %uri". url("user/login") ." using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %uri". url("user/edit") .".\n\nYour new %site membership also enables to you to login to other Drupal powered websites (e.g. http://www.drop.org/) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), $variables);
user_mail($edit["mail"], $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
user_mail(variable_get("site_mail", ini_get("sendmail_from")), $subject, t("%u has applied for an account.\n\n%uri", array("%u" => $account->name, "%uri" => path_uri() . url("admin/user/edit/$account->uid"))), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
user_mail(variable_get("site_mail", ini_get("sendmail_from")), $subject, t("%u has applied for an account.\n\n%uri", array("%u" => $account->name, "%uri" => url("admin/user/edit/$account->uid"))), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
return t("Your password and further instructions have been sent to your e-mail address.");
}
}
......
......@@ -682,6 +682,8 @@ function user_logout() {
function user_pass($edit = array()) {
global $base_url;
if ($edit["name"]) {
$account = db_fetch_object(db_query("SELECT uid, name, mail FROM users WHERE name = '%s'", $edit["name"]));
if (!$account) $error = t("Sorry. The username <i>%s</i> is not recognized.", array("%s" => $edit["name"]));
......@@ -705,7 +707,7 @@ function user_pass($edit = array()) {
** Mail new password:
*/
$variables = array("%username" => $account->name, "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => path_uri(), "%uri_brief" => path_uri(1), "%mailto" => $account->mail, "%date" => format_date(time()));
$variables = array("%username" => $account->name, "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => $base_url, "%uri_brief" => substr($base_url, strlen("http://")), "%mailto" => $account->mail, "%date" => format_date(time()));
$subject = strtr(variable_get("user_mail_pass_subject", t("Replacement login information for %username at %site")), $variables);
$body = strtr(variable_get("user_mail_pass_body", t("%username,\n\nHere is your new password for %site. You may now login to %uri". url("user/login") ." using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %uri". url("user/edit") .".\n\nYour new %site membership also enables you to login to other Drupal powered websites (e.g. http://www.drop.org/) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), $variables);
$headers = "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from";
......@@ -741,7 +743,7 @@ function user_pass($edit = array()) {
}
function user_register($edit = array()) {
global $user;
global $user, $base_url;
/*
** If we are already logged on, go to the user page instead.
......@@ -804,7 +806,7 @@ function user_register($edit = array()) {
$account = user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "rid" => _user_authenticated_id(), "rating" => 0, "status" => (variable_get("user_register", 1) == 1 ? 1 : 0)), $data));
watchdog("user", "new user: '". $edit["name"] ."' &lt;". $edit["mail"] ."&gt;", l("edit user", "admin/user/edit/$account->uid"));
$variables = array("%username" => $edit["name"], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => path_uri(), "%uri_brief" => path_uri(1), "%mailto" => $edit["mail"], "%date" => format_date(time()));
$variables = array("%username" => $edit["name"], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => $base_url, "%uri_brief" => substr($base_url, strlen("http://")), "%mailto" => $edit["mail"], "%date" => format_date(time()));
//the first user may login immediately, and receives a customized welcome e-mail.
if ($account->uid == 1) {
......@@ -834,7 +836,7 @@ function user_register($edit = array()) {
$subject = strtr(variable_get("user_mail_welcome_subject", t("User account details for %username at %site")), $variables);
$body = strtr(variable_get("user_mail_welcome_body", t("%username,\n\nThank you for registering at %site. Your account will have to be approved by the site administrator. You may now login to %uri". url("user/login") ." using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %uri". url("user/edit") .".\n\nYour new %site membership also enables to you to login to other Drupal powered websites (e.g. http://www.drop.org/) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), $variables);
user_mail($edit["mail"], $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
user_mail(variable_get("site_mail", ini_get("sendmail_from")), $subject, t("%u has applied for an account.\n\n%uri", array("%u" => $account->name, "%uri" => path_uri() . url("admin/user/edit/$account->uid"))), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
user_mail(variable_get("site_mail", ini_get("sendmail_from")), $subject, t("%u has applied for an account.\n\n%uri", array("%u" => $account->name, "%uri" => url("admin/user/edit/$account->uid"))), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
return t("Your password and further instructions have been sent to your e-mail address.");
}
}
......
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