OSDN Git Service

CHANGE: フィードとゲストアカウント作成フォームのためのスクリプトを修正
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 29 Feb 2012 00:31:24 +0000 (09:31 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 29 Feb 2012 00:31:24 +0000 (09:31 +0900)
atom.php/rsd.php/xml-rss2.phpの各スクリプトのコードをフォーマットした。
ACTION::createAccount()の返り値を修正し。
返り値を評価して処理を分岐するようcreateaccount.phpを修正。加えて、より単純なスクリプトに修正した。

action.php
atom.php
benchmark.inc
createaccount.php
index.php
nucleus/libs/ACTION.php
rsd.php
xml-rss2.php

index 42f6d1c..6363426 100644 (file)
 
 $CONF = array();
 require('./config.php');
-
-// common functions
-//include_once($DIR_LIBS . 'ACTION.php');
 include_libs('ACTION.php',true,false);
 
 $action = requestVar('action');
 $a = new ACTION();
 $errorInfo = $a->doAction($action);
 
-if ($errorInfo) {
+if ( $errorInfo )
+{
        doError($errorInfo['message'], new SKIN($errorInfo['skinid']) );
 }
-
-?>
\ No newline at end of file
index 0c8c5a9..9a3f95a 100644 (file)
--- a/atom.php
+++ b/atom.php
 header('Pragma: no-cache');
 
 $CONF = array();
-$CONF['Self'] = 'atom.php';
-
 include('./config.php');
 
-if (!$CONF['DisableSite']) {
+if ( !$CONF['DisableSite'] )
+{
        // get feed into $feed
        ob_start();
-               selectSkin('feeds/atom');
-               selector();
-               $feed = ob_get_contents();
+       selectSkin('feeds/atom');
+       selector();
+       $feed = ob_get_contents();
        ob_end_clean();
-
+       
        // create ETAG (hash of feed)
        // (HTTP_IF_NONE_MATCH has quotes around it)
        $eTag = '"' . md5($feed) . '"';
        header('Etag: ' . $eTag);
-
+       
        // compare Etag to what we got
-       if ($eTag == serverVar('HTTP_IF_NONE_MATCH') ) {
+       if ( $eTag == serverVar('HTTP_IF_NONE_MATCH') )
+       {
                header('HTTP/1.0 304 Not Modified');
                header('Content-Length: 0');
-       } else {
-               // dump feed
+       }
+       else
+       {
                echo $feed;
        }
-
 }
-
-?>
\ No newline at end of file
index 99fe504..ec4b7d8 100644 (file)
@@ -12,4 +12,3 @@ if (!function_exists('getmtime'))
 // For benchmarking
 global $StartTime;
 $StartTime = getmtime();
-?>
index f46ea12..32a378a 100644 (file)
  * @version $Id: createaccount.php 1624 2012-01-09 11:36:20Z sakamocchi $
  */
 
-       require_once "./config.php";
-       //include $DIR_LIBS."ACTION.php";
-       include_libs('ACTION.php',false,false);
-       
-       if (isset ($_POST['showform']) && $_POST['showform']==1) {
-               $showform = 1;
-       }
-       else {
-               $showform = 0;
-       }
-       sendContentType('text/html', 'createaccount');
-?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html>
-<head>
-       <title>Create Member Account</title>
-       <style type="text/css">@import url(nucleus/styles/manual.css);</style>
-</head>
-<body>
+require_once "./config.php";
+include_libs('ACTION.php',false,false);
 
-       <h1>Create Account</h1>
-
-<?php
-       // show form only if Visitors are allowed to create a Member Account
-       if ($CONF['AllowMemberCreate']==1) { 
-               // if the form is shown the first time no POST data 
-               // will be added as value for the input fields
-               if ($showform==0) {
-?>
+sendContentType('text/html', 'createaccount');
+echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
+echo "<html>\n";
+echo "<head>\n";
+echo "<title>Create Member Account</title>\n";
+echo "<style type=\"text/css\">@import url(nucleus/styles/manual.css);</style>\n";
+echo "</head>\n";
+echo "<body>\n";
+echo "<h1>Create Account</h1>\n";
 
-       <form method="post" action="createaccount.php">
-
-       <div>
-       <input type="hidden" name="showform" value="1" />
-       <input type="hidden" name="action" value="createaccount" />
+// show form only if Visitors are allowed to create a Member Account
+if ( $CONF['AllowMemberCreate'] == 1 )
+{
+       $name = '';
+       $realname ='';
+       $email = '';
+       $url = '';
        
-               Login Name (required): 
-               <br />
-               <input name="name" size="32" maxlength="32" /> <small>(only a-z, 0-9)</small>
-               <br />
-               <br />          
-               Real Name (required): 
-               <br />
-               <input name="realname" size="40" />
-               <br />
-               <br />          
-               Email (required):
-               <br />
-               <input name="email" size="40" /> <small>(must be valid, because an activation link will be sent over there)</small>
-               <br />
-               <br />          
-               URL: 
-               <br />
-               <input name="url" size="60" />
-               <br />
-               <?php
-               // add extra fields from Plugins, like NP_Profile
-               $manager->notify('RegistrationFormExtraFields', array('type' => 'createaccount.php', 'prelabel' => '', 'postlabel' => '<br />', 'prefield' => '', 'postfield' => '<br /><br />'));
-               // add a Captcha challenge or something else
-               global $manager;
-               $manager->notify('FormExtra', array('type' => 'membermailform-notloggedin'));
-               ?>
-               <br />
-               <br />                                          
-               <input type="submit" value="Create Account" />
-       </div>
-
-       </form>
-<?php
-               } // close if showfrom ...
-               else {
+       /* already submit */
+       if ( array_key_exists('showform', $_POST) && $_POST['showform'] == 1 )
+       {
+               if ( array_key_exists('name', $_POST) )
+               {
+                       $name = $_POST['name'];
+               }
+               if ( array_key_exists('realname', $_POST) )
+               {
+                       $realname = $_POST['realname'];
+               }
+               if ( array_key_exists('email', $_POST) )
+               {
+                       $email = $_POST['email'];
+               }
+               if ( array_key_exists('url', $_POST) )
+               {
+                       $url = $_POST['url'];
+               }
                // after the from is sent it will be validated
                // POST data will be added as value to treat the user with care (;-))
-       
                $a = new ACTION();
-
-               // if createAccount fails it returns an error message 
+               
                $message = $a->createAccount();
-
-               echo '<span style="font-weight:bold; color:red;">'.$message.'</span><br /><br />'; 
-?>
+               if ( $message != 1 )
+               {
+                       echo '<p style="font-weight:bold; color:red;">' . $message . "</p>\n";
+               }
+               else
+               {
+                       echo '<p>' . _MSG_ACTIVATION_SENT . "</p>\n"; 
+                       echo "<p>Return to <a href=\"{$CONF['IndexURL']}\" title=\"{$CONF['SiteName']}\">{$CONF['SiteName']}</a></p>\n";
+                       echo "</body>\n";
+                       echo "</html>\n";
+                       exit;
+               }
+       }
        
-               <form method="post" action="createaccount.php">
-
-       <div>
-       <input type="hidden" name="showform" value="1" />
-       <input type="hidden" name="action" value="createaccount" />
+       echo "<form method=\"post\" action=\"createaccount.php\">\n";
+       echo "<dl>\n";
+       echo "<dt><label for=\"name\">Login Name (required): </label></dt>\n";
+       echo "<dd><input id=\"name\"name=\"name\" value=\"{$name}\" size=\"32\" maxlength=\"32\" /><span style=\"\small\">(only a-z, 0-9)</span></dd>\n";
+       echo "<dt><label for=\"realname\">Real Name (required): </label></dt>\n";
+       echo "<dd><input id=\"realname\" name=\"realname\" value=\"{$realname}\" size=\"40\" /></dd>\n";
+       echo "<dt><label for=\"email\">Email (required): </label></dt>\n";
+       echo "<dd><input id=\"email\"name=\"email\" value=\"{$email}\" size=\"40\" /><span style=\"\small\">(must be valid, because an activation link will be sent over there)</span></dd>\n";
+       echo "<dt><label for=\"url\">URL: </label></dt>\n";
+       echo "<dd><input id=\"url\"name=\"url\" value=\"{$url}\" size=\"60\" /></dd>\n";
+       echo "<input type=\"hidden\" name=\"showform\" value=\"1\" />\n";
+       // add extra fields from Plugins, like NP_Profile
+       $manager->notify('RegistrationFormExtraFields', array('type' => 'createaccount.php', 'prelabel' => '', 'postlabel' => '<br />', 'prefield' => '', 'postfield' => '<br /><br />'));
        
-               Login Name (required): 
-               <br />
-               <input name="name" size="32" maxlength="32" <?php if(isset($_POST['name'])){echo 'value="'.ENTITY::hsc($_POST['name']).'"';}?>/> <small>(only a-z, 0-9)</small>
-               <br />
-               <br />          
-               Real Name (required): 
-               <br />
-               <input name="realname" size="40" <?php if(isset($_POST['realname'])){echo 'value="'.ENTITY::hsc($_POST['realname']).'"';}?>/>
-               <br />
-               <br />          
-               Email (required):
-               <br />
-               <input name="email" size="40" <?php if(isset($_POST['email'])){echo 'value="'.ENTITY::hsc($_POST['email']).'"';}?>/> <small>(must be valid, because an activation link will be sent over there)</small>
-               <br />
-               <br />          
-               URL: 
-               <br />
-               <input name="url" size="60" <?php if(isset($_POST['url'])){echo 'value="'.ENTITY::hsc($_POST['url']).'"';}?>/>
-               <br />
-               <?php
-               // add extra fields from plugin, like NP_Profile
-               $manager->notify('RegistrationFormExtraFields', array('type' => 'createaccount.php', 'prelabel' => '', 'postlabel' => '<br />', 'prefield' => '', 'postfield' => '<br /><br />'));
-               // add a Captcha challenge or something else
-               global $manager;
-               $manager->notify('FormExtra', array('type' => 'membermailform-notloggedin'));
-               ?>
-               <br />
-               <br />
-               <input type="submit" value="Create Account" />
-       </div>
-
-       </form>
-<?php
-               }       // close else showform ...
-
+       // add a Captcha challenge or something else
+       global $manager;
+       $manager->notify('FormExtra', array('type' => 'membermailform-notloggedin'));
+       echo "<button type=\"submit\" name=\"action\" value=\"createaccount\" />Create Account</button>\n";
+       echo "</dl>\n";
+       echo "</form>\n";
 }
-else { 
+else
+{
+       echo "<p>\n";
        echo 'Visitors are not allowed to create a Member Account.<br /><br />';
        echo 'Please contact the website administrator for more information.';
+       echo "</p>\n";
 }
-?>
-       
        
-</body>
-</html>
\ No newline at end of file
+echo "</body>\n";
+echo "</html>\n";
index c3bf487..31c1abd 100644 (file)
--- a/index.php
+++ b/index.php
@@ -9,5 +9,3 @@ $CONF['Self'] = 'index.php';
 include('./config.php');
 
 selector();
-
-?>
index c402041..44f4809 100644 (file)
@@ -286,17 +286,9 @@ class ACTION
                {
                        redirect(postVar('desturl') );
                }
-               else
-               {
-                       echo _MSG_ACTIVATION_SENT;
-                       echo '<br /><br />Return to <a href="'.$CONF['IndexURL'].'" title="'.$CONF['SiteName'].'">'.$CONF['SiteName'].'</a>';
-                       echo "\n</body>\n</html>";
-               }
-               
-               exit;
+               return 1;
        }
-
-
+       
        /**
         *  Sends a new password
         */
diff --git a/rsd.php b/rsd.php
index d9134bf..74c6af2 100644 (file)
--- a/rsd.php
+++ b/rsd.php
@@ -4,5 +4,3 @@ $CONF = array();
 include('./config.php');
 selectSkin('xml/rsd');
 selector();
-
-?>
\ No newline at end of file
index 26486c0..9ee70e7 100644 (file)
 header('Pragma: no-cache');
 
 $CONF = array();
-// removed $CONF['Self'] to let it be set in globalfunctions.php. 
-// Having value here makes all links (normal or fancy urlmodes) look like xml-rss2.php?itemid=#
-//$CONF['Self'] = 'xml-rss2.php';
-
 include('./config.php');
 
-if (!$CONF['DisableSite']) {
-
+if ( !$CONF['DisableSite'] )
+{
        // get feed into $feed
        ob_start();
        selectSkin('feeds/rss20');
        selector();
        $feed = ob_get_contents();
        ob_end_clean();
-
-       // create ETAG (hash of feed)
-       // (HTTP_IF_NONE_MATCH has quotes around it)
+       
+       /*
+        * create ETAG (hash of feed)
+        * (HTTP_IF_NONE_MATCH has quotes around it)
+        */
        $eTag = '"' . md5($feed) . '"';
        header('Etag: ' . $eTag);
-
+       
        // compare Etag to what we got
-       if ($eTag == serverVar('HTTP_IF_NONE_MATCH') ) {
+       if ( $eTag == serverVar('HTTP_IF_NONE_MATCH') )
+       {
                header('HTTP/1.0 304 Not Modified');
                header('Content-Length: 0');
-       } else {
-               // dump feed
+       }
+       else
+       {
                echo $feed;
        }
-
-} else {
-       // output empty RSS file...
-       // (because site is disabled)
-
-       echo '<' . '?xml version="1.0" encoding="' . i18n::get_current_charset() . '"?' . '>';
-
-       ?>
-       <rss version="2.0">
-               <channel>
-                       <title><?php echo ENTITY::hsc($CONF['SiteName']); ?></title>
-                       <link><?php echo ENTITY::hsc($CONF['IndexURL']); ?></link>
-                       <description></description>
-                       <docs>http://backend.userland.com/rss</docs>
-               </channel>
-       </rss>
-       <?php
 }
-
-?>
\ No newline at end of file
+// site is disabled, output empty RSS file
+else
+{
+       echo '<?xml version="1.0" encoding="' . i18n::get_current_charset() . '"?>' . "\n";
+       echo "<rss version=\"2.0\">\n";
+       echo "<channel>\n";
+       echo '<title>' . ENTITY::hsc($CONF['SiteName']) . "</title>\n";
+       echo "<link>" . ENTITY::hsc($CONF['IndexURL']) . "</link>\n";
+       echo "<description></description>\n";
+       echo "<docs>http://backend.userland.com/rss</docs>\n";
+       echo "</channel>\n";
+       echo "</rss>\n";
+}