Changeset 130

Show
Ignore:
Timestamp:
06/18/2006 04:17:50 PM (4 years ago)
Author:
NilsLindenberg
Message:

closes #236.

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/actions/usersettings.php

    r124 r130  
    88 * @author              {@link http://wikkawiki.org/MinusF MinusF} (code cleanup and validation) 
    99 * @author              {@link http://wikkawiki.org/DarTar Dario Taraborelli} (further cleanup, i18n, replaced JS dialogs with server-generated messages) 
     10 * @author              {@link http://wikkawiki.org/NilsLindenberg Nils Lindenberg} (possibility to restrict registration) 
    1011 * @since               Wikka 1.1.6.2 
    1112 * 
     
    4748if (!defined('CHANGE_BUTTON_LABEL')) define('CHANGE_BUTTON_LABEL', "Change password"); 
    4849if (!defined('REGISTER_BUTTON_LABEL')) define('REGISTER_BUTTON_LABEL', "Register"); 
     50if (!defined('REGISTER_CODE_LABEL')) define('REGISTER_CODE_LABEL', "Register Code:"); 
    4951if (!defined('QUICK_LINKS_HEADING')) define('QUICK_LINKS_HEADING', "Quick links"); 
    5052if (!defined('QUICK_LINKS')) define('QUICK_LINKS', "See a list of pages you own (MyPages) and pages you've edited (MyChanges)."); 
     
    6567if (!defined('ERROR_INVALID_REVISION_DISPLAY_LIMIT')) define('ERROR_INVALID_REVISION_DISPLAY_LIMIT', "The number of page revisions should not exceed %d."); 
    6668if (!defined('ERROR_INVALID_RECENTCHANGES_DISPLAY_LIMIT')) define('ERROR_INVALID_RECENTCHANGES_DISPLAY_LIMIT', "The number of recently changed pages should not exceed %d."); 
     69if (!defined('ERROR_REGISTER_CODE_INCORRECT')) define ('ERROR_REGISTER_CODE_INCORRECT', "Sorry, the register-code you entered was not correct!"); 
     70if (!defined('NO_REGISTRATION')) define('NO_REGISTRATION', "Registration on this wiki is not possible."); 
    6771if (!defined('REGISTRATION_SUCCEEDED')) define('REGISTRATION_SUCCEEDED', "You have successfully registered!"); 
    6872if (!defined('REGISTERED_USER_LOGIN_LABEL')) define('REGISTERED_USER_LOGIN_LABEL', "If you're already a registered user, log in here!"); 
    69 if (!defined('REGISTER_HEADING')) define('REGISTER_HEADING', "===Login/Register==="); 
     73// if (!defined('REGISTER_HEADING')) define('REGISTER_HEADING', "===Register==="); # to be used later for register-action 
     74if (!defined('LOGIN_HEADING')) define('LOGIN_HEADING', "===Login==="); 
     75if (!defined('LOGIN_REGISTER_HEADING')) define('LOGIN_REGISTER_HEADING', "===Login/Register==="); 
    7076if (!defined('WIKINAME_LABEL')) define('WIKINAME_LABEL', "Your <abbr title=\"A WikiName is formed by two or more capitalized words without space, e.g. JohnDoe\">WikiName</abbr>:"); 
    7177if (!defined('PASSWORD_LABEL')) define('PASSWORD_LABEL', "Password (%s+ chars):"); 
     
    100106$revisioncount_highlight = ''; 
    101107$changescount_highlight = ''; 
     108$registercode_highlight = ''; 
    102109 
    103110//create URL 
     
    107114$params = ($this->config['rewrite_mode'] == 1)? '?' : '&'; 
    108115 
     116// BEGIN *** Login/Logout *** 
    109117// is user trying to log out? 
    110118if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'logout')) 
     
    114122        $this->Redirect($url.$params); 
    115123} 
     124// END *** Login/Logout *** 
     125// BEGIN *** Usersettings *** 
    116126// user is still logged in 
    117127else if ($user = $this->GetUser()) 
     
    336346        print($this->FormClose()); 
    337347} 
     348// END *** Usersettings *** 
     349// BEGIN *** LOGIN/LOGOUT *** 
    338350else // user is not logged in 
    339351{ 
     
    345357 
    346358        // is user trying to log in or register? 
     359        $register = $this->GetConfigValue('allow_user_registration');  
    347360        if (isset($_POST['action']) && ($_POST['action'] == 'login')) 
    348361        { 
     362                print("hallo"); 
    349363                // if user name already exists, check password 
    350364                if (isset($_POST['name']) && $existingUser = $this->LoadUser($_POST['name'])) 
     
    365379                        } 
    366380                } 
    367                 else // otherwise, proceed to registration 
     381                // END *** Login/Logout *** 
     382                // BEGIN *** Register *** 
     383                else if ($register == '1' || $register == '2') // otherwise, proceed to registration 
    368384                { 
    369385                        $name = trim($_POST['name']); 
     
    421437                                        $password_confirm_highlight = INPUT_ERROR_STYLE; 
    422438                                        break; 
     439                                case ($register == '2' && $_POST['registercode'] !==  $this->GetConfigValue('registercode')): 
     440                                    $error = ERROR_REGISTER_CODE_INCORRECT; 
     441                        $registercode_highlight = INPUT_ERROR_STYLE; 
     442                        break; 
    423443                                default: //valid input, create user 
    424444                                        $this->Query("INSERT INTO ".$this->config['table_prefix']."users SET ". 
     
    434454                        } 
    435455                } 
    436         } 
     456        }  
     457        // END *** Register *** 
     458        // BEGIN *** Usersettings *** 
    437459        elseif  (isset($_POST['action']) && ($_POST['action'] == 'updatepass')) 
    438460        { 
     
    468490                } 
    469491        } 
    470  
     492        // END *** Usersettings *** 
     493        // BEGIN *** Login/Logout ***  
     494        // BEGIN ***  Register *** 
    471495        print($this->FormOpen()); 
    472496?> 
     
    474498        <table class="usersettings"> 
    475499        <tr> 
    476                 <td colspan="2"><?php echo $this->Format(REGISTER_HEADING) ?></td> 
     500                <td colspan="2"><?php  echo ($register == '1' || $register == '2') ? $this->Format(LOGIN_REGISTER_HEADING) : $this->Format(LOGIN_HEADING); ?></td> 
    477501                <td>&nbsp;</td> 
    478502        </tr> 
     
    504528                <td><input type="submit" value="<?php echo LOGIN_BUTTON_LABEL ?>" size="40" /></td> 
    505529        </tr> 
     530<?php 
     531        // END *** Login/Logout *** 
     532        $register = $this->GetConfigValue('allow_user_registration'); 
     533    if ($register == '1' || $register == '2') 
     534    { 
     535?> 
    506536        <tr> 
    507537                <td>&nbsp;</td> 
     
    516546                <td><input <?php echo $email_highlight; ?> name="email" size="40" value="<?php if (isset($email)){ echo $email; }?>" /></td> 
    517547        </tr> 
     548<?php 
     549            if ($register == '2') 
     550            { 
     551?> 
     552               <tr> 
     553                   <td align='right'><?php echo REGISTER_CODE_LABEL ?></td> 
     554                   <td><input <?php echo $registercode_highlight; ?> type='text' size='20' name='registercode' /></td> 
     555               </tr> 
     556<?php 
     557                } 
     558?> 
    518559        <tr> 
    519560                <td>&nbsp;</td> 
    520561                <td><input type="submit" value="<?php echo REGISTER_BUTTON_LABEL ?>" size="40" /></td> 
    521562        </tr> 
    522         </table> 
    523 <?php 
     563</table> 
     564<?php 
     565    } 
    524566        print($this->FormClose()); 
     567        // END *** Register *** 
    525568        print($this->FormOpen()); 
    526569?> 
  • trunk/setup/install.php

    r116 r130  
    302302        test("Updating FormattingRules page...", 
    303303        mysql_query("insert into ".$config["table_prefix"]."pages set tag = 'FormattingRules', body = '======Wikka Formatting Guide======\n\n<<**Note:** Anything between 2 sets of double-quotes is not formatted.<<::c::\nOnce you have read through this, test your formatting skills in the SandBox.\n----\n===1. Text Formatting===\n\n~##\"\"**I\'m bold**\"\"##\n~**I\'m bold **\n\n~##\"\"//I\'m italic text!//\"\"##\n~//I\'m italic text!//\n\n~##\"\"And I\'m __underlined__!\"\"##\n~And I\'m __underlined__!\n\n~##\"\"##monospace text##\"\"##\n~##monospace text##\n\n~##\"\"\'\'highlight text\'\'\"\"## (using 2 single-quotes)\n~\'\'highlight text\'\'\n\n~##\"\"++Strike through text++\"\"##\n~++Strike through text++\n\n~##\"\"Press #%ANY KEY#%\"\"##\n~Press #%ANY KEY#%\n\n~##\"\"@@Center text@@\"\"##\n~@@Center text@@\n\n===2. Headers===\n\nUse between five ##=## (for the biggest header) and two ##=## (for the smallest header) on both sides of a text to render it as a header.\n\n~##\"\"====== Really big header ======\"\"##\n~====== Really big header ======\n  \n~##\"\"===== Rather big header =====\"\"##\n~===== Rather big header =====\n\n~##\"\"==== Medium header ====\"\"##\n~==== Medium header ====\n\n~##\"\"=== Not-so-big header ===\"\"##\n~=== Not-so-big header ===\n\n~##\"\"== Smallish header ==\"\"##\n~== Smallish header ==\n\n===3. Horizontal separator===\n~##\"\"----\"\"##\n----\n\n===4. Forced line break===\n~##\"\"---\"\"##\n---\n\n===5. Lists and indents===\n\nYou can indent text using a **~**, a **tab** or **4 spaces** (which will auto-convert into a tab).\n\n##\"\"~This text is indented<br />~~This text is double-indented<br />&nbsp;&nbsp;&nbsp;&nbsp;This text is also indented\"\"##\n\n~This text is indented\n~~This text is double-indented\n   This text is also indented\n\nTo create bulleted/ordered lists, use the following markup (you can always use 4 spaces instead of a ##**~**##):\n\n**Bulleted lists**\n##\"\"~- Line one\"\"##\n##\"\"~- Line two\"\"##\n\n- Line one\n- Line two\n\n**Numbered lists**\n##\"\"~1) Line one\"\"##\n##\"\"~1) Line two\"\"##\n\n1) Line one\n1) Line two\n\n**Ordered lists using uppercase characters**\n##\"\"~A) Line one\"\"##\n##\"\"~A) Line two\"\"##\n\nA) Line one\nA) Line two\n\n**Ordered lists using lowercase characters**\n##\"\"~a) Line one\"\"##\n##\"\"~a) Line two\"\"##\n\na) Line one\na) Line two\n\n**Ordered lists using roman numerals**\n##\"\"~I) Line one\"\"##\n##\"\"~I) Line two\"\"##\n\n   I) Line one\nI) Line two\n\n**Ordered lists using lowercase roman numerals**\n##\"\"~i) Line one\"\"##\n##\"\"~i) Line two\"\"##\n\n i) Line one\ni) Line two\n\n===6. Inline comments===\n\nTo format some text as an inline comment, use an indent ( **~**, a **tab** or **4 spaces**) followed by a **\"\"&amp;\"\"**.\n\n**Example:**\n\n##\"\"~&amp; Comment\"\"##\n##\"\"~~&amp; Subcomment\"\"##\n##\"\"~~~&amp; Subsubcomment\"\"##\n\n~& Comment\n~~& Subcomment\n~~~& Subsubcomment\n\n===7. Images===\n\nTo place images on a Wiki page, you can use the ##image## action.\n\n**Example:**\n\n~##\"\"{{image class=\"center\" alt=\"DVD logo\" title=\"An Image Link\" url=\"images/dvdvideo.gif\" link=\"RecentChanges\"}}\"\"##\n~{{image class=\"center\" alt=\"dvd logo\" title=\"An Image Link\" url=\"images/dvdvideo.gif\" link=\"RecentChanges\"}}\n\nLinks can be external, or internal Wiki links. You don\'t need to enter a link at all, and in that case just an image will be inserted. You can use the optional classes ##left## and ##right## to float images left and right. You don\'t need to use all those attributes, only ##url## is required while ##alt## is recommended for accessibility.\n\n===8. Links===\n\nTo create a **link to a wiki page** you can use any of the following options: ---\n~1) type a ##\"\"WikiName\"\"##: --- --- ##\"\"FormattingRules\"\"## --- FormattingRules --- ---\n~1) add a forced link surrounding the page name by ##\"\"[[\"\"## and ##\"\"]]\"\"## (everything after the first space will be shown as description): --- --- ##\"\"[[SandBox Test your formatting skills]]\"\"## --- [[SandBox Test your formatting skills]] --- --- ##\"\"[[SandBox &#27801;&#31665;]]\"\"## --- [[SandBox &#27801;&#31665;]] --- ---\n~1) add an image with a link (see instructions above).\n\nTo **link to external pages**, you can do any of the following: ---\n~1) type a URL inside the page: --- --- ##\"\"http://www.example.com\"\"## --- http://www.example.com --- --- \n~1) add a forced link surrounding the URL by ##\"\"[[\"\"## and ##\"\"]]\"\"## (everything after the first space will be shown as description): --- --- ##\"\"[[http://example.com/jenna/ Jenna\'s Home Page]]\"\"## --- [[http://example.com/jenna/ Jenna\'s Home Page]] --- --- ##\"\"[[mail@example.com Write me!]]\"\"## --- [[mail@example.com Write me!]] --- ---\n~1) add an image with a link (see instructions above);\n~1) add an interwiki link (browse the [[InterWiki list of available interwiki tags]]): --- --- ##\"\"WikiPedia:WikkaWiki\"\"## --- WikiPedia:WikkaWiki --- --- ##\"\"Google:CSS\"\"## --- Google:CSS --- --- ##\"\"Thesaurus:Happy\"\"## --- Thesaurus:Happy --- ---\n\n===9. Tables===\n\nTo create a table, you can use the ##table## action.\n\n**Example:**\n\n~##\"\"{{table columns=\"3\" cellpadding=\"1\" cells=\"BIG;GREEN;FROGS;yes;yes;no;no;no;###\"}}\"\"##\n\n~{{table columns=\"3\" cellpadding=\"1\" cells=\"BIG;GREEN;FROGS;yes;yes;no;no;no;###\"}}\n\nNote that ##\"\"###\"\"## must be used to indicate an empty cell.\nComplex tables can also be created by embedding HTML code in a wiki page (see instructions below).\n\n===10. Colored Text===\n\nColored text can be created using the ##color## action:\n\n**Example:**\n\n~##\"\"{{color c=\"blue\" text=\"This is a test.\"}}\"\"##\n~{{color c=\"blue\" text=\"This is a test.\"}}\n\nYou can also use hex values:\n\n**Example:**\n\n~##\"\"{{color hex=\"#DD0000\" text=\"This is another test.\"}}\"\"##\n~{{color hex=\"#DD0000\" text=\"This is another test.\"}}\n\nAlternatively, you can specify a foreground and background color using the ##fg## and ##bg## parameters (they accept both named and hex values):\n\n**Examples:**\n\n~##\"\"{{color fg=\"#FF0000\" bg=\"#000000\" text=\"This is colored text on colored background\"}}\"\"##\n~{{color fg=\"#FF0000\" bg=\"#000000\" text=\"This is colored text on colored background\"}}\n\n~##\"\"{{color fg=\"lightgreen\" bg=\"black\" text=\"This is colored text on colored background\"}}\"\"##\n~{{color fg=\"lightgreen\" bg=\"black\" text=\"This is colored text on colored background\"}}\n\n\n===11. Floats===\n\nTo create a **left floated box**, use two ##<## characters before and after the block.\n\n**Example:**\n\n~##\"\"&lt;&lt;Some text in a left-floated box hanging around&lt;&lt; Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler.\"\"##\n\n<<Some text in a left-floated box hanging around<<Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler.\n\n::c::To create a **right floated box**, use two ##>## characters before and after the block.\n\n**Example:**\n\n~##\"\">>Some text in a right-floated box hanging around>> Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler.\"\"##\n\n   >>Some text in a right-floated box hanging around>>Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler. Some more text as a filler.\n\n::c:: Use ##\"\"::c::\"\"##  to clear floated blocks.\n\n===12. Code formatters===\n\nYou can easily embed code blocks in a wiki page using a simple markup. Anything within a code block is displayed literally. \nTo create a **generic code block** you can use the following markup:\n\n~##\"\"%% This is a code block %%\"\"##. \n\n%% This is a code block %%\n\nTo create a **code block with syntax highlighting**, you need to specify a //code formatter// (see below for a list of available code formatters). \n\n~##\"\"%%(\"\"{{color c=\"red\" text=\"php\"}}\"\")<br />&lt;?php<br />echo \"Hello, World!\";<br />?&gt;<br />%%\"\"##\n\n%%(php)\n<?php\necho \"Hello, World!\";\n?>\n%%\n\nYou can also specify an optional //starting line// number.\n\n~##\"\"%%(php;\"\"{{color c=\"red\" text=\"15\"}}\"\")<br />&lt;?php<br />echo \"Hello, World!\";<br />?&gt;<br />%%\"\"##\n\n%%(php;15)\n<?php\necho \"Hello, World!\";\n?>\n%%\n\nIf you specify a //filename//, this will be used for downloading the code.\n\n~##\"\"%%(php;15;\"\"{{color c=\"red\" text=\"test.php\"}}\"\")<br />&lt;?php<br />echo \"Hello, World!\";<br />?&gt;<br />%%\"\"##\n\n%%(php;15;test.php)\n<?php\necho \"Hello, World!\";\n?>\n%%\n\n**List of available code formatters:**\n{{table columns=\"6\" cellpadding=\"1\" cells=\"LANGUAGE;FORMATTER;LANGUAGE;FORMATTER;LANGUAGE;FORMATTER;Actionscript;actionscript;ADA;ada;Apache Log;apache;AppleScript; applescript;ASM;asm;ASP;asp;AutoIT;autoit;Bash;bash;BlitzBasic;blitzbasic;C;c;C for Macs;c_mac;c#;csharp;C++;cpp;CAD DCL;caddcl;CadLisp;cadlisp;CFDG;cfdg;ColdFusion;cfm; CSS;css;D;d;Delphi;delphi;Diff-Output;diff;DIV; div;DOS;dos;Eiffel;eiffel;Fortran;fortran;FreeBasic;freebasic;GML;gml;Groovy;groovy;HTML;html4strict;INI;ini;Inno Script;inno;Java 5;java5;Java;java;Javascript;javascript;Lisp;lisp;Lua;lua;Matlab;matlab;Microchip Assembler;mpasm;Microsoft Registry;reg;MySQL;mysql;NSIS;nsis;Objective C;objc;OpenOffice BASIC;oobas;Objective Caml;ocaml;Objective Caml (brief);ocaml-brief;Oracle 8;oracle8;Pascal;pascal;Perl;perl;PHP;php;PHP (brief);php-brief;Python;phyton;Q(uick)BASIC;qbasic;robots.txt;robots;Ruby;ruby;SAS;sas;Scheme;scheme;sdlBasic;sdlbasic;Smarty;smarty;SQL;sql;TCL/iTCL;tcl;T-SQL;tsql;Text;text;VB.NET;vbnet;VHDL;vhdl;Visual BASIC;vb;Visual Fox Pro;visualfoxpro;WinBatch;winbatch;XML;xml;###;###\"}}\n\n===13. Mindmaps===\n\nWikka has native support for [[Wikka:FreeMind mindmaps]]. There are two options for embedding a mindmap in a wiki page.\n\n**Option 1:** Upload a \"\"FreeMind\"\" file to a webserver, and then place a link to it on a wikka page:\n  ##\"\"http://yourdomain.com/freemind/freemind.mm\"\"##\nNo special formatting is necessary.\n\n**Option 2:** Paste the \"\"FreeMind\"\" data directly into a wikka page:\n~- Open a \"\"FreeMind\"\" file with a text editor.\n~- Select all, and copy the data.\n~- Browse to your Wikka site and paste the Freemind data into a page. \n\n===14. Embedded HTML===\n\nYou can easily paste HTML in a wiki page by wrapping it into two sets of doublequotes. \n\n~##&quot;&quot;[html code]&quot;&quot;##\n\n**Examples:**\n\n~##&quot;&quot;y = x<sup>n+1</sup>&quot;&quot;##\n~\"\"y = x<sup>n+1</sup>\"\"\n\n~##&quot;&quot;<acronym title=\"Cascade Style Sheet\">CSS</acronym>&quot;&quot;##\n~\"\"<acronym title=\"Cascade Style Sheet\">CSS</acronym>\"\"\n\nBy default, some HTML tags are removed by the \"\"SafeHTML\"\" parser to protect against potentially dangerous code.  The list of tags that are stripped can be found on the Wikka:SafeHTML page.\n\nIt is possible to allow //all// HTML tags to be used, see Wikka:UsingHTML for more information.\n\n----\nCategoryWiki', owner = '(Public)', note='".$upgrade_note."', user = 'WikkaInstaller', time = now(), latest = 'Y'", $dblink), "Already done? OK!", 0); 
     304case "1.1.6.2": 
     305        test(sprintf(ADDING_CONFIG_ENTRY, 'allow_user_registration'), 1); 
     306        $config["allow_user_registration"] = '1'; 
     307        test(sprintf(ADDING_CONFIG_ENTRY, 'registercode'), 1); 
     308        $config["registercode"] = ''; 
    304309case "trunk": //latest development version from the SVN repository - do not remove 
    305310        break; 
  • trunk/wikka.php

    r102 r130  
    131131        'xml_recent_changes'            => '10', 
    132132        'hide_comments'                 => '0', 
    133         'require_edit_note'             => '0',         # edit note optional (0, default), edit note required (1) edit note disabled (2) 
    134133        'anony_delete_own_comments'     => '1', 
    135134        'public_sysinfo'                        => '0',         # enable or disable public display of system information in SysInfo 
     135        'require_edit_note'             => '0',         # edit note optional (0, default), edit note required (1) edit note disabled (2) 
     136        'allow_user_registration' => '1',       # user registration disabled (0), enabled (1) or only possible with register code (2) 
     137        'registercode' => '',   # used by 'allow_user_registration' => '2' 
    136138        'double_doublequote_html'       => 'safe', 
    137139        'external_link_tail'            => '<span class="exttail">&#8734;</span>',