Fix bug where toplinks where broken
authorJehan-Guillaume (ioguix) de Rorthais <ioguix@free.fr>
Mon, 4 Jun 2012 16:30:15 +0000 (18:30 +0200)
committerJehan-Guillaume (ioguix) de Rorthais <ioguix@free.fr>
Wed, 22 Aug 2012 10:39:00 +0000 (12:39 +0200)
Bad escaping of the embeded js code in the tag.

classes/Misc.php

index 3a0dbb40a0bcc5aab87ffec0a0816d93772e3895..562e5666f1b5194293502a41b258ddd48b189205 100644 (file)
                        global $lang, $conf, $plugin_manager, $appName, $appVersion, $appLangFiles;
 
                        $server_info = $this->getServerInfo();
+                       $reqvars = $this->getRequestVars('table');
 
                        echo "<div class=\"topbar\"><table style=\"width: 100%\"><tr><td>";
 
 
                                /* top right informations when connected */
 
-                               $sql_url = "sqledit.php?{$this->href}&amp;action=";
-                               $sql_window_id = htmlentities('sqledit:'.$_REQUEST['server']);
-                               $history_url = "history.php?{$this->href}&amp;action=pophistory";
-                               $history_window_id = htmlentities('history:'.$_REQUEST['server']);
-                               $logout_shared = isset($_SESSION['sharedUsername']) ? "return confirm('{$lang['strconfdropcred']})" : '';
-
                                $toplinks = array (
                                        'sql' => array (
                                                'attr' => array (
-                                                       'href' => "{$sql_url}&action=sql",
+                                                       'href' => array (
+                                                               'url' => 'sqledit.php',
+                                                               'urlvars' => array_merge($reqvars, array (
+                                                                       'action' => 'sql'
+                                                               ))
+                                                       ),
                                                        'target' => "sqledit",
-                                                       'onclick' => "window.open('{$sql_url}&action=sql','{$sql_window_id}','toolbar=no,width=700,height=500,resizable=yes,scrollbars=yes').focus(); return false;"
+                                                       'id' => 'toplink_sql',
                                                ),
                                                'content' => $lang['strsql']
                                        ),
                                        'history' => array (
-                                               'attr' => array (
-                                                       'href' => $history_url,
-                                                       'onclick' => "window.open('{$history_url}','{$history_window_id}','toolbar=no,width=800,height=600,resizable=yes,scrollbars=yes').focus(); return false;",
+                                               'attr'=> array (
+                                                       'href' => array (
+                                                               'url' => 'history.php',
+                                                               'urlvars' => array_merge($reqvars, array (
+                                                                       'action' => 'pophistory'
+                                                               ))
+                                                       ),
+                                                       'id' => 'toplink_history',
                                                ),
                                                'content' => $lang['strhistory']
                                        ),
                                        'find' => array (
                                                'attr' => array (
-                                                       'href' => "{$sql_url}&action=find",
+                                                       'href' => array (
+                                                               'url' => 'sqledit.php',
+                                                               'urlvars' => array_merge($reqvars, array (
+                                                                       'action' => 'find'
+                                                               ))
+                                                       ),
                                                        'target' => "sqledit",
-                                                       'onclick' => "window.open('{$sql_url}&action=find','{$sql_window_id}','toolbar=no,width=700,height=500,resizable=yes,scrollbars=yes').focus(); return false;",
+                                                       'id' => 'toplink_find',
                                                ),
                                                'content' => $lang['strfind']
                                        ),
                                        'logout' => array(
                                                'attr' => array (
-                                                       'href' => "servers.php?action=logout&logoutServer=".htmlentities($server_info['host']).":".htmlentities($server_info['port']).":".htmlentities($server_info['sslmode']),
-                                                       'onclick' => $logout_shared,
+                                                       'href' => array (
+                                                               'url' => 'servers.php',
+                                                               'urlvars' => array (
+                                                                       'action' => 'logout',
+                                                                       'logoutServer' => "{$server_info['host']}:{$server_info['port']}:{$server_info['sslmode']}"
+                                                               )
+                                                       ),
+                                                       'id' => 'toplink_logout',
                                                ),
                                                'content' => $lang['strlogout']
                                        )
                                echo "<td style=\"text-align: right\">";
                                $this->printLinksList($toplinks, 'toplink');
                                echo "</td>";
+
+                               $sql_window_id = htmlentities('sqledit:'.$_REQUEST['server']);
+                               $history_window_id = htmlentities('history:'.$_REQUEST['server']);
+
+                               echo "<script type=\"text/javascript\">
+                                               $('#toplink_sql').click(function() {
+                                                       window.open($(this).attr('href'),'{$sql_window_id}','toolbar=no,width=700,height=500,resizable=yes,scrollbars=yes').focus();
+                                                       return false;
+                                               });
+
+                                               $('#toplink_history').click(function() {
+                                                       window.open($(this).attr('href'),'{$history_window_id}','toolbar=no,width=700,height=500,resizable=yes,scrollbars=yes').focus();
+                                                       return false;
+                                               });
+
+                                               $('#toplink_find').click(function() {
+                                                       window.open($(this).attr('href'),'{$sql_window_id}','toolbar=no,width=700,height=500,resizable=yes,scrollbars=yes').focus();
+                                                       return false;
+                                               });
+                                               ";
+
+                               if (isset($_SESSION['sharedUsername'])) {
+                                       printf("
+                                               $('#toplink_logout').click(function() {
+                                                       return confirm('%s');
+                                               });", str_replace("'", "\'", $lang['strconfdropcred']));
+                               }
+
+                               echo "
+                               </script>";
                        }
                        else {
                                echo "<span class=\"appname\">{$appName}</span> <span class=\"version\">{$appVersion}</span>";