PageCookery ships with a deliberately closed sign-up system: new accounts can only be added by an administrator from the back end. The modification below opens a public registration route, so visitors can create their own basic accounts.

The public form will live at ?act=register. A login page can point visitors there as well.
Create the registration template
Make a new file in the template directory and call it register.html (the name can be anything, as long as the route and template call match). Put this markup into it:
{template header}
<div id="main" class="prefix_edit">
<h2 class="nav_title">新增用户</h2>
<form action="?act=register&do=add" method="post">
用户名: <input class="input_message w150" name="username" type="text" /> 密码: <input class="input_message w150" name="password" type="password" /> <input class="image_button_submit" type="submit" value="新增用户" />
</form>
{template footer}</div>
The form is essentially borrowed from users.html, so the markup does not need further explanation; what matters is that it posts to ?act=register&do=add.
Add the register case to index.php
Open index.php in the root directory. Around the seventh line from the bottom—just before the closing } that follows the last if block—add this case:
case 'register':
if ($_GET['do'] == 'add' AND $_POST['username'] AND $_POST['password'])
{
$check = $SQL->QueryRowsArray("SELECT id FROM user WHERE username = '" . Format::Safe($_POST['username'], true) . "'");
if ($check['id'])
{
Helper::PrintJavaScript('alert(\'已经存在名为 ' . Format::Safe($_POST['username'], true) . ' 的用户.\'); window.location = \'' . $_SERVER['HTTP_REFERER'] . '\'');
}
$SQL->Insert('user', array('username', 'password'), array(Format::Safe($_POST['username'], true), Format::Safe(md5($_POST['password']), true)));
Helper::PrintJavaScript('alert(\'很高兴的通知您,你在 似水流年 上成功注册了' . Format::Safe($_POST['username'], true) . ' 此用户.\'); window.location = \'' . $_SERVER['HTTP_REFERER'] . '\'');
exit;
}
$title = SITE_NAME . ' - 用户';
$template=& new Template('register',NULL,'register');
break;
After saving, ?act=register becomes the public registration address. The handler checks whether the username is already taken, then inserts the new user with an MD5-hashed password, and sends the visitor back with an alert.
Put registration links in the navigation and login page
In template/header.html, search for 管理. Replace that line with the following code; it keeps the existing navigation entries and adds a 注 册 link:
<li><a href="{$base_url}"
<!--{if ($current == 'blog')}--> class="selected"
<!--{/if}-->>网 志</a>
</li><li><a href="?act=register">注 册</a></li>
<!--{if ($sync['api']['username'])}-->
<li><a href="http://<!--{if ($sync['api']['type'] == 'jiwai')}-->jiwai.de<!--{else}-->digu.com<!--{/if}-->/
<echo>urlencode($sync['api']['username'])</echo>/" target="_blank">
<!--{if ($sync['api']['type'] == 'jiwai')}-->叽 歪<!--{else}-->嘀 咕<!--{/if}--></a></li>
<!--{/if}--><!--{if ($Own['lastfm'])}-->
<li><a href="?act=music"<!--{if ($current == 'music')}--> class="selected"<!--{/if}-->>音乐墙</a></li>
<!--{/if}--><!--{if ($flickr['feed'])}-->
<li><a href="?act=photos"<!--{if ($current == 'photos')}--> class="selected"<!--{/if}-->>照片墙</a></li>
<!--{/if}-->
To add the link on the login page, open template/login.html and search for 登录. Replace that line with:
<div style="text-align:right"><input type="submit" value="登 录" class="login_submit" /><a href="?act=register" class="login_submit">注 册</a></div>
This makes the registration form publicly reachable. It is worth being clear about what the new account can do: this route only opens the basic user-creation step, not the full administrator user form. Fields such as the photo wall, music wall, and RSS import remain admin-only, so users who register themselves will not have those options.