INSERT INTO vars VALUES ('show_prefs_on_first_login','1','Should a user be redirected to the preferences page after first logging in?','bool','General');
UPDATE vars SET name='min_pw_request_interval',description='Length of time, in minutes, that must pass between password requests to prevent flooding a user with password mails.' WHERE name='confirms_valid_for';
ALTER TABLE users ADD COLUMN is_new_account tinyint(1) default NULL;
ALTER TABLE users CHANGE pass_confirm newpasswd varchar(12);
UPDATE blocks SET block='  <TR>\r\n   <TD COLSPAN=2 BGCOLOR=\"%%title_bgcolor%%\">%%title_font%%\r\n   <B>Create New User Account</B>%%title_font_end%%<P>\r\n   <FORM NAME=\"adduser\" METHOD=\"post\" ACTION=\"%%rootdir%%/\">\r\n   <INPUT TYPE=\"hidden\" name=\"tool\" VALUE=\"writeuser\">\r\n   <INPUT TYPE=\"hidden\" name=\"op\" VALUE=\"newuser\">\r\n   <INPUT TYPE=\"hidden\" name=\"formkey\" VALUE=\"%%formkey%%\">\r\n   </TD>\r\n  </TR>\r\n  <TR><TD COLSPAN=2><FONT COLOR=\"#FF0000\"><H3><CENTER>%%error%%</CENTER></H3></FONT></TD></TR>\r\n  <TR><TD COLSPAN=2>%%norm_font%%\r\nIn order to create an account (which is free), fill out this form. You will receive an email containing your username and autogenerated password, at the address you provide here. Use this data to login. It\'s that easy.\r\n<P>\r\nWhy is the password autogenerated? First, random passwords are typically more secure than non-random ones. Second, by requiring you to log in using a password we send you, we can make sure that the email address is valid. This makes it harder for malicious users to abuse the account creation system by creating an arbitrary number of accounts and spamming the site with stories or comments. If you do not like your autogenerated password, you can easily change it after logging in.\r\n<P>\r\nAgain, your password will be mailed to the email address you enter here, so it <B>must</B> work. Do NOT enter a spam-protected or fake email address. \r\n<P>\r\nIf you are concerned about privacy, this email does not have to be in any way traceable to you. We will never use the email you provide here for anything else, ever. All it needs to be is working, and accessible to you, at the time the account is created. \r\n  <P>\r\n  Now get started, and we hope you enjoy %%sitename%%!\r\n  %%norm_font_end%%</TD></TR>\r\n  <TR><TD COLSPAN=2>&nbsp;</TD></TR>\r\n  <TR>\r\n   <TD>\r\n   %%norm_font%%\r\n   Please enter your desired username:<BR>\r\n   %%norm_font_end%%\r\n   </TD>\r\n   <TD>\r\n   %%norm_font%%<INPUT TYPE=\"text\" NAME=\"nickname\" SIZE=30 VALUE=\"%%uname%%\">%%norm_font_end%%<BR>\r\n   </TD>\r\n  </TR>\r\n   <TD COLSPAN=2>\r\n   %%smallfont%%(Legal characters: a-z, A-Z, 0-9, space. Names may not start or end with a space, and may not contain more than one space in a row.)%%smallfont_end%%\r\n   </TD>\r\n  </TR>\r\n  <TR>\r\n   <TD>\r\n   %%norm_font%%\r\n   and a working email (this will never be made public!):<BR>\r\n   <B><FONT COLOR=\"#FF0000\">Check this for typos!</FONT></B>\r\n   %%norm_font_end%%\r\n   </TD>\r\n   <TD>\r\n   %%norm_font%%<INPUT TYPE=\"text\" NAME=\"email\" VALUE=\"%%email%%\" SIZE=30>%%norm_font_end%%\r\n   </TD>\r\n  </TR>' WHERE bid="new_user_html";
UPDATE blocks SET block='displaystory.length=6:/mode/sid{5}/,\r\ndisplaystory=/sid{5}/,\r\n\r\nuser=EVAL{\r\n  my $p = {};\r\n  if ($S->cgi->param(\'caller_op\') eq \'my\') {\r\n    unshift @path__COMMA__ $S->{NICK};\r\n  } elsif ($S->cgi->param(\'caller_op\') =~ m/^~(.+)$/) {\r\n    unshift @path__COMMA__ $1;\r\n  }\r\n  my $uid;\r\n  if ($path[0] =~ /uid:/) {\r\n    $path[0] =~ s/^uid://;\r\n    $uid = $path[0];\r\n    $path[0] = $S->get_nick_from_uid($uid);\r\n  } else {\r\n    $uid=$S->get_uid_from_nick($path[0]); \r\n  }\r\n  if ($path[1] eq \'edit\') { $path[1] = \'prefs\' }\r\n  if ($path[1] eq \'diary\') {\r\n    $p = {\r\n      op      => \'section\'__COMMA__\r\n      user    => \"diary_$uid\"__COMMA__\r\n      section => \'Diary\'__COMMA__\r\n      page    => $path[2]\r\n    };\r\n  } elsif ($path[1] =~ /comment/) {\r\n    $p->{op}      = \'search\';\r\n    $p->{type}    = \'comment_by\';\r\n    $p->{string}  = $path[0];\r\n  } elsif ($path[1] eq \'ads\') {\r\n    $p->{op}      = \'adinfo\';\r\n    $p->{ad_id}   = \"uid:$uid\";\r\n  } elsif ($path[1] eq \'stories\' || $path[1] eq \'story\') {\r\n    $p->{op}      = \'search\';\r\n    $p->{type}    = \'author\';\r\n    $p->{string}  = $path[0];\r\n  } else {\r\n    $p->{op}      = \'user\';\r\n    $p->{tool}    = $path[1];\r\n    $p->{nick}    = $path[0];\r\n  }\r\n  return $p;\r\n},\r\n\r\nsearch.length=2:/type/string/,\r\nsearch=/string/,\r\n\r\nsection=/section/page/,\r\n\r\nspecial=/page/,\r\n\r\nsubmitstory=/section/,\r\n\r\ninterface=/tool/,\r\n\r\nview_poll=/qid/,\r\n\r\nhotlist=/tool/sid{5}/new_op/page/section/,\r\n\r\ncomments.1=poll:/null/sid/cid/tool/,\r\ncomments.length=2:/sid/cid/,\r\ncomments.length=3:/sid/cid/tool/,\r\ncomments=/sid{5}/cid/tool/,\r\n\r\n\r\nadmin.1=blocks:/tool/theme/cat/,\r\nadmin.1=story:/tool/sid{5}/,\r\nadmin.1=editpoll:/tool/editqid/option/,\r\nadmin.1=vars:/tool/cat/,\r\nadmin.1=topics:/tool/tid/,\r\nadmin.1=sections:/tool/section/,\r\nadmin.1=special:/tool/id/,\r\nadmin.1=boxes:/tool/id,\r\nadmin.1=optemplates:/tool/opcode,\r\nadmin.1=groups:/tool/perm_group_id/,\r\nadmin.1=rdf:/tool/action/,\r\nadmin.1=cron:/tool/action/which/,\r\nadmin.1=ads:/tool/type/which,\r\nadmin.1=ops:/tool/opcode/,\r\nadmin=tool,\r\n\r\nprint=/sid{5}/,\r\n\r\nfzdisplay=/action/sid{5}/cid/,\r\n\r\nmain=/page/,\r\nshowad=/ad_id/,\r\nsubmitad=/step/,\r\nredirect=/ad_id/,\r\nadinfo=/ad_id/,\r\n\r\nads=/distribute,' WHERE bid="op_templates";
UPDATE blocks set block='%%norm_font%%<FONT COLOR="#FF0000"><B>New password for %%uname%% mailed.</B></FONT>%%norm_font_end%%<BR>', description='Message to inform the user that a new password has been mailed to them' WHERE bid='login_mailed_message';
UPDATE blocks set block='%%norm_font%%<FONT COLOR="#FF0000"><B>Could not mail password for %%uname%%.</B></FONT>%%norm_font_end%%<BR>' WHERE bid='login_mail_failed';
DELETE FROM ops WHERE op='confirmpass';
