plugins/SpecialAdmin.php
changeset 328 dc838fd61a06
parent 326 ab66d6d1f1f4
child 329 0437a7cf1acc
--- a/plugins/SpecialAdmin.php	Wed Dec 19 23:04:17 2007 -0500
+++ b/plugins/SpecialAdmin.php	Thu Dec 20 22:23:07 2007 -0500
@@ -219,6 +219,35 @@
     if ( in_array($_POST['lockout_policy'], array('disable', 'captcha', 'lockout')) )
       setConfig('lockout_policy', $_POST['lockout_policy']);
     
+    // Avatar settings
+    setConfig('avatar_enable', ( isset($_POST['avatar_enable']) ? '1' : '0' ));
+    // for these next three values, set the config value if it's a valid integer; this is
+    // done by using strval(intval($foo)) === $foo, which flattens $foo to an integer and
+    // then converts it back to a string. This effectively verifies that var $foo is both
+    // set and that it's a valid string representing an integer.
+    setConfig('avatar_max_size', ( strval(intval($_POST['avatar_max_size'])) === $_POST['avatar_max_size'] ? $_POST['avatar_max_size'] : '10240' ));
+    setConfig('avatar_max_width', ( strval(intval($_POST['avatar_max_width'])) === $_POST['avatar_max_width'] ? $_POST['avatar_max_width'] : '96' ));
+    setConfig('avatar_max_height', ( strval(intval($_POST['avatar_max_height'])) === $_POST['avatar_max_height'] ? $_POST['avatar_max_height'] : '96' ));
+    setConfig('avatar_enable_anim', ( isset($_POST['avatar_enable_anim']) ? '1' : '0' ));
+    setConfig('avatar_upload_file', ( isset($_POST['avatar_upload_file']) ? '1' : '0' ));
+    setConfig('avatar_upload_http', ( isset($_POST['avatar_upload_http']) ? '1' : '0' ));
+    
+    if ( is_dir(ENANO_ROOT . '/' . $_POST['avatar_directory']) )
+    {
+      if ( preg_match('/^([A-z0-9_-]+)(\/([A-z0-9_-]+))*$/', $_POST['avatar_directory']) )
+      {
+        setConfig('avatar_directory', $_POST['avatar_directory']);
+      }
+      else
+      {
+        echo '<div class="error-box">You have entered an invalid avatar directory.</div>';
+      }
+    }
+    else
+    {
+      echo '<div class="error-box">You have entered an invalid avatar directory.</div>';
+    }
+    
     echo '<div class="info-box">Your changes to the site configuration have been saved.</div><br />';
     
   }
@@ -245,7 +274,7 @@
       
     <!-- Wiki mode -->
       
-      <tr><th colspan="2">Wiki mode</th></tr>
+      <tr><th class="subhead" colspan="2">Wiki mode</th></tr>
       
       <tr>
         <td class="row3" rowspan="2">
@@ -278,7 +307,7 @@
       
     <!-- Site statistics -->
     
-      <tr><th colspan="2">Statistics and hit counting</th></tr>
+      <tr><th class="subhead" colspan="2">Statistics and hit counting</th></tr>
       
       <tr>
         <td class="row1">Enano has the ability to show statistics for every page on the site. This allows you to keep very close track of who is visiting your site, and from where.<br /><br />Unfortunately, some users don't like being logged. For this reason, you should state clearly what is logged (usually the username or IP address, current time, page name, and referer URL) in your privacy policy. If your site is primarily geared towards children, and you are a United States citizen, you are required to have a privacy policy stating exactly what is being logged under the terms of the Childrens' Online Privacy Protection Act.</td>
@@ -287,7 +316,7 @@
       
     <!-- Comment options -->
       
-      <tr><th colspan="2">Comment system</th></tr>
+      <tr><th class="subhead" colspan="2">Comment system</th></tr>
       <tr><td class="row1"><label for="enable-comments"><b>Enable the comment system</b></label>                      </td><td class="row1"><input name="enable-comments"  id="enable-comments"  type="checkbox" <?php if(getConfig('enable_comments')=='1')  echo('CHECKED '); ?>/></td></tr>
       <tr><td class="row2"><label for="comment-approval">Require approval before article comments can be shown</label></td><td class="row2"><input name="comment-approval" id="comment-approval" type="checkbox" <?php if(getConfig('approve_comments')=='1') echo('CHECKED '); ?>/></td></tr>
       <tr><td class="row1">Guest comment posting allowed                                                              </td><td class="row1"><label><input name="comments_need_login" type="radio" value="0" <?php if(getConfig('comments_need_login')=='0') echo 'CHECKED '; ?>/> Yes</label>
@@ -308,28 +337,9 @@
       
       -->
       
-    <!-- enanocms.org link -->
-    
-    <tr>
-      <th colspan="2">Promote Enano</th>
-    </tr>
-    <tr>
-      <td class="row3">
-        If you think Enano is nice, or if you want to show your support for the Enano team, you can do so by placing a link to the Enano
-        homepage in your Links sidebar block. You absolutely don't have to do this, and you won't get degraded support if you don't. Because
-        Enano is still relatively new in the CMS world, it needs all the attention it can get - and you can easily help to spread the word
-        using this link.
-      </td>
-      <td class="row1">
-        <label>
-          <input name="enano_powered_link" type="checkbox" <?php if(getConfig('powered_btn') == '1') echo 'checked="checked"'; ?> />&nbsp;&nbsp;Place a link to enanocms.org on the sidebar
-        </label>
-      </td>
-    </tr>
-      
     <!-- Site disablement -->
     
-      <tr><th colspan="2">Disable all site access</th></tr>
+      <tr><th class="subhead" colspan="2">Disable all site access</th></tr>
       
       <tr>
         <td class="row3" rowspan="2">Disabling the site allows you to work on the site without letting non-administrators see or use it.</td>
@@ -343,10 +353,20 @@
           </div>
         </td>
       </tr>
+      
+    </table>
+    </div>
+        
+    <div class="tblholder">
+    <table border="0" width="100%" cellspacing="1" cellpadding="4">
+    
+    <tr>
+      <th colspan="2">Users and communication</th>
+    </tr>
     
     <!-- Account activation -->
       
-      <tr><th colspan="2">User account activation</th></tr>
+      <tr><th class="subhead" colspan="2">User account activation</th></tr>
       
       <tr>
         <td class="row3" colspan="2">
@@ -357,7 +377,7 @@
       </tr>
       
       <tr>
-        <td class="row1">Account activation:</td><td class="row1">
+      <td class="row1" style="width: 50%;">Account activation:</td><td class="row1">
           <?php
           echo '<label><input'; if(getConfig('account_activation') == 'disable') echo ' checked="checked"'; echo ' type="radio" name="account_activation" value="disable" /> Disable registration</label><br />';
           echo '<label><input'; if(getConfig('account_activation') != 'user' && getConfig('account_activation') != 'admin' && getConfig('account_activation') != 'disable') echo ' checked="checked"'; echo ' type="radio" name="account_activation" value="none" /> None</label>';
@@ -369,7 +389,7 @@
       
     <!-- Account lockout -->
     
-      <tr><th colspan="2">Account lockouts</th></tr>
+      <tr><th class="subhead" colspan="2">Account lockouts</th></tr>
       
       <tr><td class="row3" colspan="2">Configure Enano to prevent or restrict logins for a specified period of time if a user enters an incorrect password a specific number of times.</td></tr>
       
@@ -404,7 +424,7 @@
       
     <!-- Password strength -->
       
-      <tr><th colspan="2">Password strength</th></tr>
+      <tr><th class="subhead" colspan="2">Password strength</th></tr>
       
       <tr>
         <td class="row2">
@@ -428,22 +448,125 @@
       
     <!-- E-mail options -->
     
-    <tr><th colspan="2">E-mail sent from the site</th></tr>
-    <tr><td class="row1">E-mail sending method:<br /><small>Try using the built-in e-mail method first. If that doesn't work, you will need to enter valid SMTP information here.</small></td>
-        <td class="row1"><label><input <?php if(getConfig('smtp_enabled') != '1') echo 'checked="checked"'; ?> type="radio" name="emailmethod" value="phpmail" />PHP's built-in mail() function</label><br />
-                         <label><input <?php if(getConfig('smtp_enabled') == '1') echo 'checked="checked"'; ?> type="radio" name="emailmethod" value="smtp" />Use an external SMTP server</label></td>
-        </tr>
-    <tr><td class="row2">SMTP hostname:<br /><small>This option only applies to the external SMTP mode.</small></td>
-        <td class="row2"><input value="<?php echo getConfig('smtp_server'); ?>" name="smtp_host" type="text" size="30" /></td>
-        </tr>
-    <tr><td class="row1">SMTP credentials:<br /><small>This option only applies to the external SMTP mode.</small></td>
-        <td class="row1">Username: <input value="<?php echo getConfig('smtp_user'); ?>" name="smtp_user" type="text" size="30" /><br />
-            Password: <input value="<?php if(getConfig('smtp_password') != false) echo 'XXXXXXXXXXXX'; ?>" name="smtp_pass" type="password" size="30" /></td>
-        </tr>
+      <tr><th class="subhead" colspan="2">E-mail sent from the site</th></tr>
+      <tr><td class="row1">E-mail sending method:<br /><small>Try using the built-in e-mail method first. If that doesn't work, you will need to enter valid SMTP information here.</small></td>
+          <td class="row1"><label><input <?php if(getConfig('smtp_enabled') != '1') echo 'checked="checked"'; ?> type="radio" name="emailmethod" value="phpmail" />PHP's built-in mail() function</label><br />
+                           <label><input <?php if(getConfig('smtp_enabled') == '1') echo 'checked="checked"'; ?> type="radio" name="emailmethod" value="smtp" />Use an external SMTP server</label></td>
+          </tr>
+      <tr><td class="row2">SMTP hostname:<br /><small>This option only applies to the external SMTP mode.</small></td>
+          <td class="row2"><input value="<?php echo getConfig('smtp_server'); ?>" name="smtp_host" type="text" size="30" /></td>
+          </tr>
+      <tr><td class="row1">SMTP credentials:<br /><small>This option only applies to the external SMTP mode.</small></td>
+          <td class="row1">Username: <input value="<?php echo getConfig('smtp_user'); ?>" name="smtp_user" type="text" size="30" /><br />
+              Password: <input value="<?php if(getConfig('smtp_password') != false) echo 'XXXXXXXXXXXX'; ?>" name="smtp_pass" type="password" size="30" /></td>
+          </tr>
+        
+    <!-- Avatar support -->
+    
+      <tr>
+        <th class="subhead" colspan="2">Avatars</th>
+      </tr>
+      
+      <tr>
+        <td class="row3" colspan="2">
+          Avatars are small images that users can display on their profiles and in comments.
+        </th>
+      </tr>
+      
+      <tr>
+        <td class="row1">
+          Enable avatar support:<br />
+          <small>Supported formats are JPEG, PNG, and GIF&trade;.</small>
+        </td>
+        <td class="row1">
+          <label><input type="checkbox" name="avatar_enable" <?php if ( getConfig('avatar_enable') == '1' ) echo 'checked="checked" '; ?>/> Enabled</label>
+        </td>
+      </tr>
+      
+      <tr>
+        <td class="row2">
+          Maximum avatar file size:<br />
+          <small>For smaller sites, the highest value for this should be about 50KB, 51200. Larger sites with more visitors will likely want to use something much smaller, such as 10KB.</small>
+        </td>
+        <td class="row2">
+          <input type="text" name="avatar_max_size" size="7" <?php if ( ($x = getConfig('avatar_max_size')) !== false ) echo "value=\"$x\" "; else echo "value=\"10240\" "; ?>/> bytes
+        </td>
+      </tr>
+      
+      <tr>
+        <td class="row1">
+          Maximum avatar dimensions:<br />
+          <small>The format is width &#215; height. Typically you want to have this square (the same width and height). These are only maximum dimensions; users are not prevented from having smaller images.</small>
+        </td>
+        <td class="row1">
+          <input type="text" name="avatar_max_width" size="7" <?php if ( $x = getConfig('avatar_max_width') ) echo "value=\"$x\" "; else echo "value=\"150\" "; ?>/> &#215;
+          <input type="text" name="avatar_max_height" size="7" <?php if ( $x = getConfig('avatar_max_height') ) echo "value=\"$x\" "; else echo "value=\"150\" "; ?>/> pixels
+        </td>
+      </tr>
+      
+      <tr>
+        <td class="row2">
+          Allow animated avatars:<br />
+          <small>If this is checked, users can upload APNG and Animated GIF&trade; avatars. Sometimes such images can be specifically made to be distracting, like rapidly flashing images. If this is unchecked, these formats will be blocked, and only still PNGs and GIFs will be allowed.</small>
+        </td>
+        <td class="row2">
+          <label><input type="checkbox" name="avatar_enable_anim" <?php if ( getConfig('avatar_enable_anim') == '1' ) echo 'checked="checked" '; ?>/> Don't block animated images</label>
+        </td>
+      </tr>
+      
+      <tr>
+        <td class="row1">
+          Allowed upload methods:<br />
+          <small></small>
+        </td>
+        <td class="row1">
+          <label><input type="checkbox" name="avatar_upload_file" <?php if ( getConfig('avatar_upload_file') == '1' || getConfig('avatar_upload_file') === false ) echo 'checked="checked" '; ?>/> Allow users to upload image files from their computers</label><br />
+          <label><input type="checkbox" name="avatar_upload_http" <?php if ( getConfig('avatar_upload_http') == '1' || getConfig('avatar_upload_http') === false ) echo 'checked="checked" '; ?>/> Allow users to enter a URL to their desired avatar</label>
+        </td>
+      </tr>
+      
+      <tr>
+        <td class="row2">
+          Avatar storage directory:<br />
+          <small>This should be relative to your Enano root and should contain only alphanumeric characters and forward slashes, even if your server runs Windows.</small>
+        </td>
+        <td class="row2">
+          <input type="text" name="avatar_directory" size="30" <?php if ( $x = getConfig('avatar_directory') ) echo "value=\"$x\" "; else echo "value=\"files/avatars\" "; ?>/>
+        </td>
+      </tr>
+        
+    </table>
+    </div>
+        
+    <div class="tblholder">
+    <table border="0" width="100%" cellspacing="1" cellpadding="4">
+    
+    <tr>
+      <th colspan="2">Sidebar links</th>
+    </tr>
+    
+    <!-- enanocms.org link -->
+    
+    <tr>
+      <th colspan="2" class="subhead">Promote Enano</th>
+    </tr>
+    <tr>
+    <td class="row3" style="width: 50%;">
+        If you think Enano is nice, or if you want to show your support for the Enano team, you can do so by placing a link to the Enano
+        homepage in your Links sidebar block. You absolutely don't have to do this, and you won't get degraded support if you don't. Because
+        Enano is still relatively new in the CMS world, it needs all the attention it can get - and you can easily help to spread the word
+        using this link.
+      </td>
+      <td class="row1">
+        <label>
+          <input name="enano_powered_link" type="checkbox" <?php if(getConfig('powered_btn') == '1') echo 'checked="checked"'; ?> />&nbsp;&nbsp;Place a link to enanocms.org on the sidebar
+        </label>
+      </td>
+    </tr>
       
     <!-- SourceForge.net logo -->
       
-      <tr><th colspan="2">SourceForge.net logo</th></tr>
+      <tr><th class="subhead" colspan="2">SourceForge.net logo</th></tr>
       
       <tr>
         <td colspan="2" class="row3">
@@ -488,8 +611,8 @@
       
     <!-- W3C validator buttons -->
       
-      <tr><th colspan="2">W3C compliance logos</th></tr>
-      <tr><th colspan="2" class="subhead">Enano generates (by default) Valid XHTML 1.1 code, plus valid CSS.  If you want to show this off, check the appropriate boxes below.</th></tr>
+      <tr><th class="subhead" colspan="2">W3C compliance logos</th></tr>
+      <tr><td colspan="2" class="row3">Enano generates (by default) Valid XHTML 1.1 code, plus valid CSS.  If you want to show this off, check the appropriate boxes below.</th></tr>
       
       <tr><td class="row1"><label for="w3c-vh32">HTML 3.2</label>     </td><td class="row1"><input type="checkbox" <?php if(getConfig('w3c_vh32')=='1')     echo('CHECKED '); ?> id="w3c-vh32"     name="w3c-vh32"     /></td></tr>
       <tr><td class="row2"><label for="w3c-vh40">HTML 4.0</label>     </td><td class="row2"><input type="checkbox" <?php if(getConfig('w3c_vh40')=='1')     echo('CHECKED '); ?> id="w3c-vh40"     name="w3c-vh40"     /></td></tr>
@@ -500,13 +623,19 @@
 
     <!-- DefectiveByDesign.org ad -->      
       
-      <tr><th colspan="2">Defective By Design Anti-DRM button</th></tr>
+      <tr><th class="subhead" colspan="2">Defective By Design Anti-DRM button</th></tr>
       <tr><td colspan="2" class="row3"><b>The Enano project is strongly against Digital Restrictions Management.</b> DRM removes the freedoms that every consumer should have: to freely copy and use digital media items they legally purchased to their own devices. Showing your opposition to DRM is as easy as checking the box below to place a link to <a href="http://www.defectivebydesign.org">DefectiveByDesign.org</a> on your sidebar.</td></tr>
       <tr><td class="row1"><label for="dbdbutton">Help stop DRM by placing a link to DBD on the sidebar!</label></td><td class="row1"><input type="checkbox" name="dbdbutton" id="dbdbutton" <?php if(getConfig('dbd_button')=='1')  echo('checked="checked" '); ?>/></td></tr>
       
     <!-- Save button -->
+    
+    </table>
+    </div>
+        
+    <div class="tblholder">
+    <table border="0" width="100%" cellspacing="1" cellpadding="4">
       
-      <tr><th style="text-align: right" class="subhead" colspan="2"><input type=submit name=submit value="Save changes" /></th></tr>
+      <tr><th colspan="2"><input type="submit" name="submit" value="Save changes" /></th></tr>
       
     </table>
   </div>