Index: /extensions/AdditionalPages/additional_page.php
===================================================================
--- /extensions/AdditionalPages/additional_page.php	(revision 9311)
+++ /extensions/AdditionalPages/additional_page.php	(revision 9312)
@@ -5,5 +5,4 @@
 global $template, $user;
 
-$page['section'] = 'additional_page';
 $identifier = $page['ap_homepage'] ? $conf['additional_pages']['homepage'] : $tokens[1];
 
@@ -21,4 +20,5 @@
 $row = pwg_db_fetch_assoc(pwg_query($query));
 
+// Page not found
 if (empty($row))
 {
@@ -27,4 +27,5 @@
 }
 
+// Redirect with permalink if exist
 if (is_numeric($identifier) and !empty($row['permalink']) and !$page['ap_homepage'])
 {
@@ -32,24 +33,18 @@
 }
 
-if (!$page['ap_homepage'] and $row['id'] == $conf['additional_pages']['homepage'])
+// Access controls
+if (!is_admin() or (!is_admin() xor $page['ap_homepage']))
 {
-  redirect(make_index_url());
-}
+  // authorized level
+  if ($user['level'] < $row['level'])
+  {
+    page_forbidden(l10n('You are not authorized to access the requested page'));
+  }
 
-$page['additional_page'] = array(
-  'id' => $row['id'],
-  'permalink' => @$row['permalink'],
-  'title' => trigger_event('AP_render_content', $row['title']),
-  'content' => trigger_event('AP_render_content', $row['content']),
-  'standalone' => ($row['standalone'] == 'true')
-);
-
-if (!is_admin() and !$page['ap_homepage'])
-{
   // authorized users
-  if (!empty($row['users']))
+  if (isset($row['users']))
   {
     $authorized_users = explode(',', $row['users']);
-    if (!is_admin() and $conf['additional_pages']['user_perm'] and !in_array($user['status'], $authorized_users))
+    if (!in_array($user['status'], $authorized_users))
     {
       if ($page['ap_homepage']) return;
@@ -61,9 +56,11 @@
   if (!empty($row['groups']))
   {
-    $q = 'SELECT *
-  FROM ' . USER_GROUP_TABLE . '
-  WHERE user_id = ' . $user['id'] . ' AND group_id IN (' . $row['groups'] . ');';
-    $array = mysql_fetch_array(pwg_query($q));
-    if (!is_admin() and $conf['additional_pages']['group_perm'] and empty($array))
+    $query = 'SELECT group_id
+FROM ' . USER_GROUP_TABLE . '
+WHERE user_id = ' . $user['id'] . '
+  AND group_id IN (' . $row['groups'] . ')
+;';
+    $groups = array_from_query($query, 'group_id');
+    if (empty($groups))
     {
       if ($page['ap_homepage']) return;
@@ -71,18 +68,22 @@
     }
   }
-
-  // authorized level
-  if ($user['level'] < $row['level'])
-  {
-    page_forbidden(l10n('You are not authorized to access the requested page'));
-  }
 }
 
 // Display standalone page
-if ($page['additional_page']['standalone'])
+if ($row['standalone'] == 'true')
 {
-  echo $page['additional_page']['content'];
+  echo $row['content'];
   exit;
 }
+
+// Page initilization
+$page['section'] = 'additional_page';
+
+$page['additional_page'] = array(
+  'id' => $row['id'],
+  'permalink' => @$row['permalink'],
+  'title' => trigger_event('AP_render_content', $row['title']),
+  'content' => trigger_event('AP_render_content', $row['content']),
+);
 
 add_event_handler('loc_end_index', 'ap_set_index');
Index: /extensions/AdditionalPages/admin/add_page.inc.php
===================================================================
--- /extensions/AdditionalPages/admin/add_page.inc.php	(revision 9311)
+++ /extensions/AdditionalPages/admin/add_page.inc.php	(revision 9312)
@@ -20,5 +20,5 @@
 }
 
-// Enregistrement
+// Submit form
 if (isset($_POST['save']))
 {
@@ -106,11 +106,12 @@
     }
 
-    // Enregistrement du fichier de sauvegarde
+    // Backup file
     mkgetdir($conf['local_data_dir'], MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
-    mkgetdir($conf['local_data_dir'].'/additional_pages_backup', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
+    mkgetdir($conf['local_data_dir'].'/additional_pages_backup', MKGETDIR_PROTECT_HTACCESS&~MKGETDIR_DIE_ON_ERROR);
     $sav_file = @fopen($conf['local_data_dir'].'/additional_pages_backup/' . $edited_page['id'] . '.txt', "w");
     @fwrite($sav_file, "Title: ".$_POST['title']."\nPermalink: ".$_POST['permalink']."\nLanguage: ".$_POST['lang']."\n\n" . $_POST['ap_content']);
     @fclose($sav_file);
 
+    // Redirect to admin pannel or additional page
     if (isset($_GET['redirect']))
     {
@@ -131,5 +132,5 @@
 }
 
-// Selection des langues
+// Language options
 $options['ALL'] = l10n('ap_all_lang');
 $selected = 'ALL';
Index: /extensions/AdditionalPages/admin/edit_page.inc.php
===================================================================
--- /extensions/AdditionalPages/admin/edit_page.inc.php	(revision 9311)
+++ /extensions/AdditionalPages/admin/edit_page.inc.php	(revision 9312)
@@ -8,9 +8,10 @@
 }
 
-// Suppression
+// Delete
 if (isset($_REQUEST['delete']) and isset($_GET['edit']))
 {
 	pwg_query('DELETE FROM ' . ADD_PAGES_TABLE . ' WHERE id = ' . $_GET['edit'] . ';');
   @unlink($conf['local_data_dir'].'/additional_pages_backup/' . $_GET['edit'] . '.txt');
+
   if ($conf['additional_pages']['homepage'] == $_GET['edit'])
   {
@@ -18,13 +19,16 @@
     conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($conf['additional_pages'])));
   }
+
   redirect($my_base_url.'&page_deleted=');
 }
 
-$q = 'SELECT id , lang , title , content , users , groups , level , permalink, standalone
+// Load page data
+$query = '
+SELECT id , lang , title , content , users , groups , level , permalink, standalone
 FROM ' . ADD_PAGES_TABLE . '
-WHERE id = '.$_GET['edit'].';';
+WHERE id = '.$_GET['edit'].'
+;';
+$edited_page = pwg_db_fetch_assoc(pwg_query($query));
 
-$edited_page = pwg_db_fetch_assoc(pwg_query($q));
-$page_title = l10n('ap_modify');
 $edited_page['users'] = !empty($edited_page['users']) ? explode(',', $edited_page['users']) : array();
 $edited_page['groups'] = !empty($edited_page['groups']) ? explode(',', $edited_page['groups']) : array();
@@ -32,6 +36,6 @@
 $edited_page['standalone'] = ($edited_page['standalone'] == 'true');
 
-// Lien de suppression
 $template->assign('delete', true);
+$page_title = l10n('ap_modify');
 
 include(AP_PATH.'admin/add_page.inc.php');
Index: /extensions/AdditionalPages/admin/template/add_page.tpl
===================================================================
--- /extensions/AdditionalPages/admin/template/add_page.tpl	(revision 9311)
+++ /extensions/AdditionalPages/admin/template/add_page.tpl	(revision 9312)
@@ -94,5 +94,6 @@
       <div>
         <a href="#" onClick="jQuery('input[name^=\'groups\']').attr('checked', 'checked');return false;">{'ap_select_all'|@translate}</a> /
-        <a href="#" onClick="jQuery('input[name^=\'groups\']').attr('checked', '');return false;">{'ap_unselect_all'|@translate}</a>
+        <a href="#" onClick="jQuery('input[name^=\'groups\']').attr('checked', '');return false;">{'ap_unselect_all'|@translate}</a> &nbsp; 
+        <i>{'ap_guest'|@translate}</i>
       </div>
     </li>
@@ -112,5 +113,5 @@
 		<input class="submit" type="submit" value="{'ap_save'|@translate}" name="save">
 		{if isset($delete)}
-		<input class="submit" type="submit" value="{'ap_delete'|@translate}" name="delete" onclick="return confirm('Are you sure?'|@translate);"/>
+		<input class="submit" type="submit" value="{'ap_delete'|@translate}" name="delete" onclick="return confirm('{'Are you sure?'|@translate}');"/>
 		{/if}
 		</tr>
Index: /extensions/AdditionalPages/main.inc.php
===================================================================
--- /extensions/AdditionalPages/main.inc.php	(revision 9311)
+++ /extensions/AdditionalPages/main.inc.php	(revision 9312)
@@ -19,7 +19,9 @@
 $conf['additional_pages'] = @unserialize($conf['additional_pages']);
 
+// Need upgrade?
 if (!isset($conf['additional_pages']['level_perm']))
   include(AP_PATH.'admin/upgrade.inc.php');
 
+// Admin menu
 function additional_pages_admin_menu($menu)
 {
@@ -30,4 +32,5 @@
 }
 
+// Section init
 function section_init_additional_page()
 {
@@ -43,4 +46,5 @@
 }
 
+// Menubar
 function register_ap_menubar_blocks($menu_ref_arr)
 {
@@ -58,9 +62,9 @@
   if ( ($block = $menu->get_block( 'mbAdditionalPages' ) ) != null )
   {
-    $query = 'SELECT DISTINCT id, title, permalink, GROUP_CONCAT(groups)
+    $query = 'SELECT DISTINCT id, title, permalink
 FROM ' . ADD_PAGES_TABLE . '
 LEFT JOIN ' . USER_GROUP_TABLE . '
   ON user_id = '.$user['id'].'
-WHERE (lang = "' . $user['language'] . '" OR lang IS NULL)
+WHERE (lang IS NULL OR lang = "'.$user['language'].'")
   AND (users IS NULL OR users LIKE "%'.$user['status'].'%")
   AND (groups IS NULL OR groups REGEXP CONCAT("(^|,)",group_id,"(,|$)"))
