OSDN Git Service

Security fix against XSS attack to createaccount.php on registerglobals=ON environment.
authorkmorimatsu <kmorimatsu@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Sat, 5 Mar 2011 21:26:34 +0000 (21:26 +0000)
committerkmorimatsu <kmorimatsu@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Sat, 5 Mar 2011 21:26:34 +0000 (21:26 +0000)
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/trunk@1149 1ca29b6e-896d-4ea0-84a5-967f57386b96

utf8/createaccount.php

index afae4e3..00af4a1 100644 (file)
@@ -22,45 +22,32 @@ require_once "./config.php";
 //include $DIR_LIBS."ACTION.php";\r
 include_libs('ACTION.php',false,false);\r
 \r
-if (isset ($_POST['showform'])&&$_POST['showform']==1) {\r
-       $showform = 1;\r
-}\r
-else {\r
-       $showform = 0;\r
-}\r
+sendContentType('text/html', 'createaccount', _CHARSET);\r
+\r
 ?>\r
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
 <html <?php echo _HTML_XML_NAME_SPACE_AND_LANG_CODE; ?>>\r
-       <head>\r
-               <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET; ?>" />\r
-               <title><?php echo _CREATE_ACCOUNT_TITLE ?></title>\r
-               <style type="text/css">@import url(nucleus/styles/manual.css);</style>\r
-       </head>\r
-       <body>\r
+<head>\r
+       <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET; ?>" />\r
+       <title><?php echo _CREATE_ACCOUNT_TITLE; ?></title>\r
+       <style type="text/css">@import url(nucleus/styles/manual.css);</style>\r
+</head>\r
+<body>\r
 \r
        <h1><?php echo _CREATE_ACCOUNT0; ?></h1>\r
 <?php\r
 // show form only if Visitors are allowed to create a Member Account\r
 if ($CONF['AllowMemberCreate']==1) { \r
        if (isset($_POST['showform']) && $_POST['showform'] == 1) {\r
-               include $DIR_LIBS . 'ACTION.php';\r
                // after the from is sent it will be validated\r
                // POST data will be added as value to treat the user with care (;-))\r
+       \r
                $a = new ACTION();\r
+\r
                // if createAccount fails it returns an error message \r
-               $message = '<span style="font-weight:bold; color:red;">' . htmlspecialchars($a->createAccount()) . '</span><br /><br />';\r
-               if (isset($_POST['name']))\r
-                       $name    = 'value="' . htmlspecialchars($_POST['name']) . '" ';\r
-               if (isset($_POST['realname']))\r
-                       $realname = 'value="' . htmlspecialchars($_POST['realname']) . '" ';\r
-               if (isset($_POST['email']))\r
-                       $email  = 'value="' . htmlspecialchars($_POST['email']) . '" ';\r
-               if (isset($_POST['url']))\r
-                       $url      = 'value="' . htmlspecialchars($_POST['url']) . '" ';\r
-//             $showform = 1;\r
-//     } else {\r
-//             $showform = 0;\r
-               echo $message;\r
+               $message = $a->createAccount();\r
+\r
+               echo '<span style="font-weight:bold; color:red;">'.$message.'</span><br /><br />'; \r
        }\r
 ?>\r
                <form method="post" action="createaccount.php">\r
@@ -69,46 +56,37 @@ if ($CONF['AllowMemberCreate']==1) {
                                <input type="hidden" name="action" value="createaccount" />\r
                                <?php echo _CREATE_ACCOUNT_LOGIN_NAME; ?>\r
                                <br />\r
-                               <input name="name" size="32" maxlength="32" <?php echo $name; ?>/> <small><?php echo _CREATE_ACCOUNT_LOGIN_NAME_VALID; ?></small>\r
+                               <input name="name" size="32" maxlength="32" value="<?php echo htmlspecialchars(postVar('name')); ?>" /> <small><?php echo _CREATE_ACCOUNT_LOGIN_NAME_VALID; ?></small>\r
                                <br />\r
                                <br />\r
                                <?php echo _CREATE_ACCOUNT_REAL_NAME; ?>\r
                                <br />\r
-                               <input name="realname" size="40" <?php echo $realname; ?>/>\r
+                               <input name="realname" size="40" value="<?php echo htmlspecialchars(postVar('realname')); ?>" />\r
                                <br />\r
                                <br />\r
                                <?php echo _CREATE_ACCOUNT_EMAIL; ?>\r
                                <br />\r
-                               <input name="email" size="40" <?php echo $email; ?>/> <small><?php echo _CREATE_ACCOUNT_EMAIL2; ?></small>\r
+                               <input name="email" size="40" value="<?php echo htmlspecialchars(postVar('email')); ?>" /> <small><?php echo _CREATE_ACCOUNT_EMAIL2; ?></small>\r
                                <br />\r
                                <br />\r
                                <?php echo _CREATE_ACCOUNT_URL; ?>\r
                                <br />\r
-                               <input name="url" size="60" <?php echo $url; ?>/>\r
+                               <input name="url" size="60" value="<?php echo htmlspecialchars(postVar('url')); ?>" />\r
                                <br />\r
-<?php\r
-               global $manager;\r
+               <?php\r
                // add extra fields from Plugins, like NP_Profile\r
-               $data = array(\r
-                       'type'    => 'createaccount.php',\r
-                       'prelabel'  => '',\r
-                       'postlabel' => '<br />',\r
-                       'prefield'  => '',\r
-                       'postfield' => '<br /><br />'\r
-               );\r
-               $manager->notify('RegistrationFormExtraFields', $data);\r
+               $manager->notify('RegistrationFormExtraFields', array('type' => 'createaccount.php', 'prelabel' => '', 'postlabel' => '<br />', 'prefield' => '', 'postfield' => '<br /><br />'));\r
                // add a Captcha challenge or something else\r
                $manager->notify('FormExtra', array('type' => 'membermailform-notloggedin'));\r
-?>\r
-                               <br />\r
-                               <br />\r
-                               <input type="submit" value="<?php echo _CREATE_ACCOUNT_SUBMIT; ?>" />\r
-                       </div>\r
-               </form>\r
+               ?>\r
+               <br />\r
+               <br />\r
+               <input type="submit" value="<?php echo _CREATE_ACCOUNT_SUBMIT; ?>" />\r
+       </div>\r
+\r
+       </form>\r
 <?php\r
-       }       // close else showform ...\r
-}\r
-else {\r
+} else {\r
        echo _CREATE_ACCOUNT1;\r
        echo _CREATE_ACCOUNT2;\r
 }\r