public inbox for [email protected]  
help / color / mirror / Atom feed
Remembering the last used mirror
9+ messages / 2 participants
[nested] [flat]

* Remembering the last used mirror
@ 2007-03-18 19:41 Magnus Hagander <[email protected]>
  0 siblings, 0 replies; 9+ messages in thread

From: Magnus Hagander @ 2007-03-18 19:41 UTC (permalink / raw)
  To: pgsql-www

Hi!

I've added code to remember the last mirror used (using a cookie) and
automatically download from that mirror the next time the same user
comes in to the site. You can see it in action at
http://magnus-master.pgadmin.org/ftp/.

Right now, it's set to redirect to the last used mirror after 5 seconds.
Before I commit the code, does anybody have a different idea on how long
that time should be? (Or for that matter, does anybody think this whole
thing is a crappy idea?)

//Magnus




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Remembering the last used mirror
@ 2007-03-18 20:34 Dave Page <[email protected]>
  2007-03-18 21:42 ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Dave Page @ 2007-03-18 20:34 UTC (permalink / raw)
  To: Magnus Hagander <[email protected]>; +Cc: pgsql-www



> ------- Original Message -------
> From: Magnus Hagander <[email protected]>
> To: PostgreSQL www <[email protected]>
> Sent: 18/03/07, 19:41:35
> Subject: [pgsql-www] Remembering the last used mirror
> 
>  (Or for that matter, does anybody think this whole
> thing is a crappy idea?)

Yes, we used to do that and it was a real pita that caused nothing but trouble. Please do not commit.

/D



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Remembering the last used mirror
  2007-03-18 20:34 Re: Remembering the last used mirror Dave Page <[email protected]>
@ 2007-03-18 21:42 ` Magnus Hagander <[email protected]>
  2007-03-19 08:51   ` Re: Remembering the last used mirror Dave Page <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Magnus Hagander @ 2007-03-18 21:42 UTC (permalink / raw)
  To: Dave Page <[email protected]>; +Cc: pgsql-www

Dave Page wrote:
> 
>>  (Or for that matter, does anybody think this whole
>> thing is a crappy idea?)
> 
> Yes, we used to do that and it was a real pita that caused nothing but trouble. 

Really? That must've been before my time, 'cuz I don't remember any of
that. Out of curiosity, exactly what were the issues, if you recall?
(Not questioning you, just want to know given that so many others to it
that way..)

> Please do not commit.

Ok, I won't.


//Magnus



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Remembering the last used mirror
  2007-03-18 20:34 Re: Remembering the last used mirror Dave Page <[email protected]>
  2007-03-18 21:42 ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
@ 2007-03-19 08:51   ` Dave Page <[email protected]>
  2007-03-19 09:01     ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Dave Page @ 2007-03-19 08:51 UTC (permalink / raw)
  To: Magnus Hagander <[email protected]>; pgsql-www

Magnus Hagander wrote:
> Dave Page wrote:
>>>  (Or for that matter, does anybody think this whole
>>> thing is a crappy idea?)
>> Yes, we used to do that and it was a real pita that caused nothing but trouble. 
> 
> Really? That must've been before my time, 'cuz I don't remember any of
> that. 

It almost certainly was, back when Vince did most of the web stuff.

> Out of curiosity, exactly what were the issues, if you recall?
> (Not questioning you, just want to know given that so many others to it
> that way..)

Well it was slightly different back then so what you have now may be OK
- I just want to make sure it's gonna work this time before
inadvertently annoying people!

Back then, the front page of the website was an auto-redirect to one of
the mirror sites. This used to lead to two problems:

- If the site you got directed to was down or slow, it was a nightmare
to get to another mirror because the auto-redirect kicked in instantly
when you hit the back button. This shouldn't be a problem this time as
now I'm in a position to look at what you've done, I can see you display
the page, a warning and give a delay before redirecting.

- After the auto-redirect had kicked in, some browsers (notably, IE)
misbehave and won't respond to the stop or back button for some time -
seemingly whilst they wait for the initial connection to succeed or
timeout. This could also be a PITA, but should be purely a browser issue
with the delay you've included (it magnified the annoyance levels caused
by the bad design previously).

So I *think* the main issues that auto-redirecting had last time round
are not problems with your code.

One thought that does spring to mind though, what happens if the mirror
used previously has dropped out of use when you return? Will it still
default to it?

Regards, Dave.



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Remembering the last used mirror
  2007-03-18 20:34 Re: Remembering the last used mirror Dave Page <[email protected]>
  2007-03-18 21:42 ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
  2007-03-19 08:51   ` Re: Remembering the last used mirror Dave Page <[email protected]>
@ 2007-03-19 09:01     ` Magnus Hagander <[email protected]>
  2007-03-19 09:22       ` Re: Remembering the last used mirror Dave Page <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Magnus Hagander @ 2007-03-19 09:01 UTC (permalink / raw)
  To: Dave Page <[email protected]>; +Cc: pgsql-www

On Mon, Mar 19, 2007 at 08:51:48AM +0000, Dave Page wrote:
> Magnus Hagander wrote:
> > Dave Page wrote:
> >>>  (Or for that matter, does anybody think this whole
> >>> thing is a crappy idea?)
> >> Yes, we used to do that and it was a real pita that caused nothing but trouble. 
> > 
> > Really? That must've been before my time, 'cuz I don't remember any of
> > that. 
> 
> It almost certainly was, back when Vince did most of the web stuff.

That was certainly way back. And I *do* remember there being problems
around that. I thoguht yo were referring to ftp downloads specifically.

> > Out of curiosity, exactly what were the issues, if you recall?
> > (Not questioning you, just want to know given that so many others to it
> > that way..)
> 
> Well it was slightly different back then so what you have now may be OK
> - I just want to make sure it's gonna work this time before
> inadvertently annoying people!

:-) Yeah, that's why I brought it up before I committed anything.


> Back then, the front page of the website was an auto-redirect to one of
> the mirror sites. This used to lead to two problems:
> 
> - If the site you got directed to was down or slow, it was a nightmare
> to get to another mirror because the auto-redirect kicked in instantly
> when you hit the back button. This shouldn't be a problem this time as
> now I'm in a position to look at what you've done, I can see you display
> the page, a warning and give a delay before redirecting.

Right, this is the very reason why I want to discuss that timeout of 5
seconds. It will direct you off there in 5 seconds. If the site is very
slow, you can click on another link. If the site is 404 (but hasn't been
picked up by the mirror checkign script yet), you will get redirected to
that 404 page. But at least in my tests with firefox, if I then hit
back, I get to the mirror list and it will *not* redirect me again. But
that's a client-side thing, so it might be different in different
browsers.


> - After the auto-redirect had kicked in, some browsers (notably, IE)
> misbehave and won't respond to the stop or back button for some time -
> seemingly whilst they wait for the initial connection to succeed or
> timeout. This could also be a PITA, but should be purely a browser issue
> with the delay you've included (it magnified the annoyance levels caused
> by the bad design previously).

I haven't seen that with any other sites, so maybe it's just been fixed
in more recent versions of the browsers. There have been a couple coming
out since that time :-)


> So I *think* the main issues that auto-redirecting had last time round
> are not problems with your code.
> 
> One thought that does spring to mind though, what happens if the mirror
> used previously has dropped out of use when you return? Will it still
> default to it?

No, then it will not show a default mirror at all - it will look like
you had never picked a mirror.

I'll attach a diff for the actual code, so you can check that part out.
Should've done that the first time :-)

//Magnus


Index: template/common.html
===================================================================
RCS file: /usr/local/cvsroot/pgweb/portal/template/common.html,v
retrieving revision 1.37
diff -c -r1.37 common.html
*** template/common.html	12 Mar 2007 16:00:46 -0000	1.37
--- template/common.html	19 Mar 2007 09:00:18 -0000
***************
*** 18,23 ****
--- 18,26 ----
      <script type="text/javascript" src="{master_server}/external/tinymce/tiny_mce.js"></script>
      <script type="text/javascript" src="/layout/js/tinymce.js"></script>
  <!-- END include_tinymce_scripts -->
+ <!-- BEGIN extra_header_data -->
+ {extra_header_data}
+ <!-- END extra_header_data -->
      <script src="http://www.google-analytics.com/urchin.js"; type="text/javascript"></script><script type="text/javascript">_uacct = "UA-1345454-1";urchinTracker();</script>
    </head>
    <body>
Index: template/download.html
===================================================================
RCS file: /usr/local/cvsroot/pgweb/portal/template/download.html,v
retrieving revision 1.10
diff -c -r1.10 download.html
*** template/download.html	18 Mar 2007 17:55:59 -0000	1.10
--- template/download.html	19 Mar 2007 09:00:18 -0000
***************
*** 16,28 ****
  <p><a href="ftp://ftp.postgresql.org/">func_lang("Download PostgreSQL from the primary site")</a></p>
  <!-- END no_mirrors_block -->
  
  <!-- BEGIN near_mirrors_block -->
  <p><b>func_lang("We think these mirrors are near you:")</b></p>
  <table border="0" width="100%">
      <!-- BEGIN near_mirror_row_loop -->
      <tr>
          <!-- BEGIN near_mirror_cell_loop -->
!         <td style="text-align: center; width: 20%; white-space: nowrap;"><img src="http://www.postgresql.org/layout/images/flags/{img}" alt="{country}" width="32" height="21" style="border: 1px" /><br/>{country}<br/><!-- BEGIN mirror_http_link --><a href="{master_server}/redir?{httpurl}">http</a> | <!-- END mirror_http_link --><a href="{master_server}/redir?{url}">ftp</a><br />&nbsp;</td>
          <!-- END near_mirror_cell_loop -->
          <!-- BEGIN near_mirror_cell_empty -->
          <td>&nbsp;</td>
--- 16,37 ----
  <p><a href="ftp://ftp.postgresql.org/">func_lang("Download PostgreSQL from the primary site")</a></p>
  <!-- END no_mirrors_block -->
  
+ <!-- BEGIN last_mirror_block -->
+ <p><b>func_lang("You have used this mirror before:")</b></p>
+ <p>
+ <b><a href="{master_server}/redir?{url}">{urlh}</a></b>
+ </p>
+ <p>Your download will start automatically from this mirror in 5 seconds unless you select
+ another mirror in the list below.</p>
+ <!-- END last_mirror_block -->
+ 
  <!-- BEGIN near_mirrors_block -->
  <p><b>func_lang("We think these mirrors are near you:")</b></p>
  <table border="0" width="100%">
      <!-- BEGIN near_mirror_row_loop -->
      <tr>
          <!-- BEGIN near_mirror_cell_loop -->
!         <td style="text-align: center; width: 20%; white-space: nowrap;"><img src="http://www.postgresql.org/layout/images/flags/{img}" alt="{country}" width="32" height="21" style="border: 1px" /><br/>{country}<br/><!-- BEGIN mirror_http_link --><a href="{master_server}/redir?setmir={mirid}&typ=h&url={httpurl}">http</a> | <!-- END mirror_http_link --><a href="{master_server}/redir?setmir={mirid}&typ=f&url={url}">ftp</a><br />&nbsp;</td>
          <!-- END near_mirror_cell_loop -->
          <!-- BEGIN near_mirror_cell_empty -->
          <td>&nbsp;</td>
***************
*** 38,44 ****
      <!-- BEGIN std_mirror_row_loop -->
      <tr>
          <!-- BEGIN std_mirror_cell_loop -->
!         <td style="text-align: center; width: 20%; white-space: nowrap;"><img src="http://www.postgresql.org/layout/images/flags/{img}" alt="{country}" width="32" height="21" style="border: 1px" /><br/>{country}<br/><!-- BEGIN mirror_http_link_std --><a href="{master_server}/redir?{httpurl}">http</a> | <!-- END mirror_http_link_std --><a href="{master_server}/redir?{url}">ftp</a><br />&nbsp;</td>
          <!-- END std_mirror_cell_loop -->
          <!-- BEGIN std_mirror_cell_empty -->
          <td>&nbsp;</td>
--- 47,53 ----
      <!-- BEGIN std_mirror_row_loop -->
      <tr>
          <!-- BEGIN std_mirror_cell_loop -->
!         <td style="text-align: center; width: 20%; white-space: nowrap;"><img src="http://www.postgresql.org/layout/images/flags/{img}" alt="{country}" width="32" height="21" style="border: 1px" /><br/>{country}<br/><!-- BEGIN mirror_http_link_std --><a href="{master_server}/redir?setmir={mirid}&typ=h&url={httpurl}">http</a> | <!-- END mirror_http_link_std --><a href="{master_server}/redir?setmir={mirid}&typ=f&url={url}">ftp</a><br />&nbsp;</td>
          <!-- END std_mirror_cell_loop -->
          <!-- BEGIN std_mirror_cell_empty -->
          <td>&nbsp;</td>
Index: system/redir.php
===================================================================
RCS file: /usr/local/cvsroot/pgweb/portal/system/redir.php,v
retrieving revision 1.5
diff -c -r1.5 redir.php
*** system/redir.php	12 Mar 2007 14:51:43 -0000	1.5
--- system/redir.php	19 Mar 2007 09:00:18 -0000
***************
*** 2,8 ****
     require_once './global/settings.php';
  
     // Get the URL and hostname
!    $url = urldecode($_SERVER['QUERY_STRING']);
     $bits = parse_url($url);
     $scheme = $bits['scheme'];
     $host = $bits['host'];
--- 2,18 ----
     require_once './global/settings.php';
  
     // Get the URL and hostname
!    if (isset($_GET['url'])) {
!       $url = $_GET['url'];
!       if (isset($_GET['setmir']) && isset($_GET['typ'])) {
!          if ($_GET['typ'] == 'h' || $_GET['typ'] == 'f') {
!             setcookie('dlmirror', intval($_GET['setmir']), time()+60*60*24*300);
!             setcookie('dlmirrortype', $_GET['typ'], time()+60*60*24*300);
!          }
!       }
!    }
!    else 
!       $url = urldecode($_SERVER['QUERY_STRING']);
     $bits = parse_url($url);
     $scheme = $bits['scheme'];
     $host = $bits['host'];
Index: system/page/mirrors.php
===================================================================
RCS file: /usr/local/cvsroot/pgweb/portal/system/page/mirrors.php,v
retrieving revision 1.13
diff -c -r1.13 mirrors.php
*** system/page/mirrors.php	18 Mar 2007 17:55:59 -0000	1.13
--- system/page/mirrors.php	19 Mar 2007 09:00:18 -0000
***************
*** 11,16 ****
--- 11,22 ----
  
      function Render() {
          $file = isset($_GET['file'])?$_GET['file']:'';
+         if (isset($_COOKIE['dlmirror']) && isset($_COOKIE['dlmirrortype'])) {
+             $lastmirrid = intval($_COOKIE['dlmirror']);
+             $lastmirrtype = $_COOKIE['dlmirrortype'];
+         }
+         else
+             $lastmirrid = -1;
  
          $this->tpl->touchBlock('ftp_mirror_greeting');
  
***************
*** 18,24 ****
  
          $this->tpl->setVariable('file', htmlentities($file));
  
!         $rs = $this->pg_query("SELECT CASE WHEN mirror_index = 0 THEN ''::text ELSE mirror_index::text END || '.' || country_code || '.postgresql.org' AS hostname, host_port AS port, host_path AS path, country_name AS country, country_code, alternate_protocol FROM mirrors WHERE mirror_type='ftp' AND mirror_active AND NOT mirror_private AND mirror_dns AND mirror_last_rsync > (now() - '48 hrs'::interval) ORDER BY country_name, alternate_protocol DESC, mirror_index");
          if (pg_num_rows($rs) == 0)
              throw new Exception('No mirrors were found');
  
--- 24,30 ----
  
          $this->tpl->setVariable('file', htmlentities($file));
  
!         $rs = $this->pg_query("SELECT CASE WHEN mirror_index = 0 THEN ''::text ELSE mirror_index::text END || '.' || country_code || '.postgresql.org' AS hostname, host_port AS port, host_path AS path, country_name AS country, country_code, alternate_protocol, id FROM mirrors WHERE mirror_type='ftp' AND mirror_active AND NOT mirror_private AND mirror_dns AND mirror_last_rsync > (now() - '48 hrs'::interval) ORDER BY country_name, alternate_protocol DESC, mirror_index");
          if (pg_num_rows($rs) == 0)
              throw new Exception('No mirrors were found');
  
***************
*** 35,41 ****
              $this->tpl->setVariable(array(
                  'url'     => urlencode('ftp://ftp'; . $mirror['hostname'] . (0 < intval($mirror['port'])? ':' . $mirror['port']: '') . $mirror['path'] . $mirror['file']),
                  'img'     => str_replace(' ', '', $mirror['country']) . '.gif',
!                 'country' => ucwords($mirror['country'])
              ));
              if ($mirror['alternate_protocol'] == 't')
                  $this->tpl->setVariable('httpurl', 'http://ftp'; . $mirror['hostname'] . $mirror['path'] . $mirror['file']);
--- 41,48 ----
              $this->tpl->setVariable(array(
                  'url'     => urlencode('ftp://ftp'; . $mirror['hostname'] . (0 < intval($mirror['port'])? ':' . $mirror['port']: '') . $mirror['path'] . $mirror['file']),
                  'img'     => str_replace(' ', '', $mirror['country']) . '.gif',
!                 'country' => ucwords($mirror['country']),
!                 'mirid'  => $mirror['id']
              ));
              if ($mirror['alternate_protocol'] == 't')
                  $this->tpl->setVariable('httpurl', 'http://ftp'; . $mirror['hostname'] . $mirror['path'] . $mirror['file']);
***************
*** 52,57 ****
--- 59,86 ----
                      $this->tpl->parse('std_mirror_row_loop');
                  }
              }
+             if ($lastmirrid == $mirror['id']) {
+                 // used this mirror the last time
+                 if ($lastmirrtype == 'f')
+                     $host = 'ftp://ftp'; . $mirror['hostname'];
+                 elseif ($lastmirrtype == 'h') {
+                     if ($mirror['alternate_protocol'] == 't')
+                         $host = 'http://ftp'; . $mirror['hostname'];
+                     else
+                         continue; // requested http, but http no longer available
+                 }
+                 else
+                     continue; // Unknown type, so don't show it at all
+ 
+                 $url = $host . (0 < intval($mirror['port'])? ':' . $mirror['port']: '') . $mirror['path'] . $mirror['file'];
+                 $this->tpl->setVariable(array(
+                     'url' => urlencode($url),
+                     'urlh' => htmlentities($host)
+                 ));
+                 $this->tpl->parse('last_mirror_block');
+ 
+                 $this->tpl->setVariable('extra_header_data', '<meta http-equiv="refresh" content="5;' . $url . '" />');
+             }
          }
  
          // Add some empty cells if needed


Attachments:

  [text/plain] autodownload.patch (10.3K, 2-autodownload.patch)
  download | inline diff:
Index: template/common.html
===================================================================
RCS file: /usr/local/cvsroot/pgweb/portal/template/common.html,v
retrieving revision 1.37
diff -c -r1.37 common.html
*** template/common.html	12 Mar 2007 16:00:46 -0000	1.37
--- template/common.html	19 Mar 2007 09:00:18 -0000
***************
*** 18,23 ****
--- 18,26 ----
      <script type="text/javascript" src="{master_server}/external/tinymce/tiny_mce.js"></script>
      <script type="text/javascript" src="/layout/js/tinymce.js"></script>
  <!-- END include_tinymce_scripts -->
+ <!-- BEGIN extra_header_data -->
+ {extra_header_data}
+ <!-- END extra_header_data -->
      <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script><script type="text/javascript">_uacct = "UA-1345454-1";urchinTracker();</script>
    </head>
    <body>
Index: template/download.html
===================================================================
RCS file: /usr/local/cvsroot/pgweb/portal/template/download.html,v
retrieving revision 1.10
diff -c -r1.10 download.html
*** template/download.html	18 Mar 2007 17:55:59 -0000	1.10
--- template/download.html	19 Mar 2007 09:00:18 -0000
***************
*** 16,28 ****
  <p><a href="ftp://ftp.postgresql.org/">func_lang("Download PostgreSQL from the primary site")</a></p>
  <!-- END no_mirrors_block -->
  
  <!-- BEGIN near_mirrors_block -->
  <p><b>func_lang("We think these mirrors are near you:")</b></p>
  <table border="0" width="100%">
      <!-- BEGIN near_mirror_row_loop -->
      <tr>
          <!-- BEGIN near_mirror_cell_loop -->
!         <td style="text-align: center; width: 20%; white-space: nowrap;"><img src="http://www.postgresql.org/layout/images/flags/{img}" alt="{country}" width="32" height="21" style="border: 1px" /><br/>{country}<br/><!-- BEGIN mirror_http_link --><a href="{master_server}/redir?{httpurl}">http</a> | <!-- END mirror_http_link --><a href="{master_server}/redir?{url}">ftp</a><br />&nbsp;</td>
          <!-- END near_mirror_cell_loop -->
          <!-- BEGIN near_mirror_cell_empty -->
          <td>&nbsp;</td>
--- 16,37 ----
  <p><a href="ftp://ftp.postgresql.org/">func_lang("Download PostgreSQL from the primary site")</a></p>
  <!-- END no_mirrors_block -->
  
+ <!-- BEGIN last_mirror_block -->
+ <p><b>func_lang("You have used this mirror before:")</b></p>
+ <p>
+ <b><a href="{master_server}/redir?{url}">{urlh}</a></b>
+ </p>
+ <p>Your download will start automatically from this mirror in 5 seconds unless you select
+ another mirror in the list below.</p>
+ <!-- END last_mirror_block -->
+ 
  <!-- BEGIN near_mirrors_block -->
  <p><b>func_lang("We think these mirrors are near you:")</b></p>
  <table border="0" width="100%">
      <!-- BEGIN near_mirror_row_loop -->
      <tr>
          <!-- BEGIN near_mirror_cell_loop -->
!         <td style="text-align: center; width: 20%; white-space: nowrap;"><img src="http://www.postgresql.org/layout/images/flags/{img}" alt="{country}" width="32" height="21" style="border: 1px" /><br/>{country}<br/><!-- BEGIN mirror_http_link --><a href="{master_server}/redir?setmir={mirid}&typ=h&url={httpurl}">http</a> | <!-- END mirror_http_link --><a href="{master_server}/redir?setmir={mirid}&typ=f&url={url}">ftp</a><br />&nbsp;</td>
          <!-- END near_mirror_cell_loop -->
          <!-- BEGIN near_mirror_cell_empty -->
          <td>&nbsp;</td>
***************
*** 38,44 ****
      <!-- BEGIN std_mirror_row_loop -->
      <tr>
          <!-- BEGIN std_mirror_cell_loop -->
!         <td style="text-align: center; width: 20%; white-space: nowrap;"><img src="http://www.postgresql.org/layout/images/flags/{img}" alt="{country}" width="32" height="21" style="border: 1px" /><br/>{country}<br/><!-- BEGIN mirror_http_link_std --><a href="{master_server}/redir?{httpurl}">http</a> | <!-- END mirror_http_link_std --><a href="{master_server}/redir?{url}">ftp</a><br />&nbsp;</td>
          <!-- END std_mirror_cell_loop -->
          <!-- BEGIN std_mirror_cell_empty -->
          <td>&nbsp;</td>
--- 47,53 ----
      <!-- BEGIN std_mirror_row_loop -->
      <tr>
          <!-- BEGIN std_mirror_cell_loop -->
!         <td style="text-align: center; width: 20%; white-space: nowrap;"><img src="http://www.postgresql.org/layout/images/flags/{img}" alt="{country}" width="32" height="21" style="border: 1px" /><br/>{country}<br/><!-- BEGIN mirror_http_link_std --><a href="{master_server}/redir?setmir={mirid}&typ=h&url={httpurl}">http</a> | <!-- END mirror_http_link_std --><a href="{master_server}/redir?setmir={mirid}&typ=f&url={url}">ftp</a><br />&nbsp;</td>
          <!-- END std_mirror_cell_loop -->
          <!-- BEGIN std_mirror_cell_empty -->
          <td>&nbsp;</td>
Index: system/redir.php
===================================================================
RCS file: /usr/local/cvsroot/pgweb/portal/system/redir.php,v
retrieving revision 1.5
diff -c -r1.5 redir.php
*** system/redir.php	12 Mar 2007 14:51:43 -0000	1.5
--- system/redir.php	19 Mar 2007 09:00:18 -0000
***************
*** 2,8 ****
     require_once './global/settings.php';
  
     // Get the URL and hostname
!    $url = urldecode($_SERVER['QUERY_STRING']);
     $bits = parse_url($url);
     $scheme = $bits['scheme'];
     $host = $bits['host'];
--- 2,18 ----
     require_once './global/settings.php';
  
     // Get the URL and hostname
!    if (isset($_GET['url'])) {
!       $url = $_GET['url'];
!       if (isset($_GET['setmir']) && isset($_GET['typ'])) {
!          if ($_GET['typ'] == 'h' || $_GET['typ'] == 'f') {
!             setcookie('dlmirror', intval($_GET['setmir']), time()+60*60*24*300);
!             setcookie('dlmirrortype', $_GET['typ'], time()+60*60*24*300);
!          }
!       }
!    }
!    else 
!       $url = urldecode($_SERVER['QUERY_STRING']);
     $bits = parse_url($url);
     $scheme = $bits['scheme'];
     $host = $bits['host'];
Index: system/page/mirrors.php
===================================================================
RCS file: /usr/local/cvsroot/pgweb/portal/system/page/mirrors.php,v
retrieving revision 1.13
diff -c -r1.13 mirrors.php
*** system/page/mirrors.php	18 Mar 2007 17:55:59 -0000	1.13
--- system/page/mirrors.php	19 Mar 2007 09:00:18 -0000
***************
*** 11,16 ****
--- 11,22 ----
  
      function Render() {
          $file = isset($_GET['file'])?$_GET['file']:'';
+         if (isset($_COOKIE['dlmirror']) && isset($_COOKIE['dlmirrortype'])) {
+             $lastmirrid = intval($_COOKIE['dlmirror']);
+             $lastmirrtype = $_COOKIE['dlmirrortype'];
+         }
+         else
+             $lastmirrid = -1;
  
          $this->tpl->touchBlock('ftp_mirror_greeting');
  
***************
*** 18,24 ****
  
          $this->tpl->setVariable('file', htmlentities($file));
  
!         $rs = $this->pg_query("SELECT CASE WHEN mirror_index = 0 THEN ''::text ELSE mirror_index::text END || '.' || country_code || '.postgresql.org' AS hostname, host_port AS port, host_path AS path, country_name AS country, country_code, alternate_protocol FROM mirrors WHERE mirror_type='ftp' AND mirror_active AND NOT mirror_private AND mirror_dns AND mirror_last_rsync > (now() - '48 hrs'::interval) ORDER BY country_name, alternate_protocol DESC, mirror_index");
          if (pg_num_rows($rs) == 0)
              throw new Exception('No mirrors were found');
  
--- 24,30 ----
  
          $this->tpl->setVariable('file', htmlentities($file));
  
!         $rs = $this->pg_query("SELECT CASE WHEN mirror_index = 0 THEN ''::text ELSE mirror_index::text END || '.' || country_code || '.postgresql.org' AS hostname, host_port AS port, host_path AS path, country_name AS country, country_code, alternate_protocol, id FROM mirrors WHERE mirror_type='ftp' AND mirror_active AND NOT mirror_private AND mirror_dns AND mirror_last_rsync > (now() - '48 hrs'::interval) ORDER BY country_name, alternate_protocol DESC, mirror_index");
          if (pg_num_rows($rs) == 0)
              throw new Exception('No mirrors were found');
  
***************
*** 35,41 ****
              $this->tpl->setVariable(array(
                  'url'     => urlencode('ftp://ftp' . $mirror['hostname'] . (0 < intval($mirror['port'])? ':' . $mirror['port']: '') . $mirror['path'] . $mirror['file']),
                  'img'     => str_replace(' ', '', $mirror['country']) . '.gif',
!                 'country' => ucwords($mirror['country'])
              ));
              if ($mirror['alternate_protocol'] == 't')
                  $this->tpl->setVariable('httpurl', 'http://ftp' . $mirror['hostname'] . $mirror['path'] . $mirror['file']);
--- 41,48 ----
              $this->tpl->setVariable(array(
                  'url'     => urlencode('ftp://ftp' . $mirror['hostname'] . (0 < intval($mirror['port'])? ':' . $mirror['port']: '') . $mirror['path'] . $mirror['file']),
                  'img'     => str_replace(' ', '', $mirror['country']) . '.gif',
!                 'country' => ucwords($mirror['country']),
!                 'mirid'  => $mirror['id']
              ));
              if ($mirror['alternate_protocol'] == 't')
                  $this->tpl->setVariable('httpurl', 'http://ftp' . $mirror['hostname'] . $mirror['path'] . $mirror['file']);
***************
*** 52,57 ****
--- 59,86 ----
                      $this->tpl->parse('std_mirror_row_loop');
                  }
              }
+             if ($lastmirrid == $mirror['id']) {
+                 // used this mirror the last time
+                 if ($lastmirrtype == 'f')
+                     $host = 'ftp://ftp' . $mirror['hostname'];
+                 elseif ($lastmirrtype == 'h') {
+                     if ($mirror['alternate_protocol'] == 't')
+                         $host = 'http://ftp' . $mirror['hostname'];
+                     else
+                         continue; // requested http, but http no longer available
+                 }
+                 else
+                     continue; // Unknown type, so don't show it at all
+ 
+                 $url = $host . (0 < intval($mirror['port'])? ':' . $mirror['port']: '') . $mirror['path'] . $mirror['file'];
+                 $this->tpl->setVariable(array(
+                     'url' => urlencode($url),
+                     'urlh' => htmlentities($host)
+                 ));
+                 $this->tpl->parse('last_mirror_block');
+ 
+                 $this->tpl->setVariable('extra_header_data', '<meta http-equiv="refresh" content="5;' . $url . '" />');
+             }
          }
  
          // Add some empty cells if needed


^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Remembering the last used mirror
  2007-03-18 20:34 Re: Remembering the last used mirror Dave Page <[email protected]>
  2007-03-18 21:42 ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
  2007-03-19 08:51   ` Re: Remembering the last used mirror Dave Page <[email protected]>
  2007-03-19 09:01     ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
@ 2007-03-19 09:22       ` Dave Page <[email protected]>
  2007-03-19 15:16         ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Dave Page @ 2007-03-19 09:22 UTC (permalink / raw)
  To: Magnus Hagander <[email protected]>; +Cc: pgsql-www

Magnus Hagander wrote:
> No, then it will not show a default mirror at all - it will look like
> you had never picked a mirror.

OK, that's good, and I can't see any of the previous issues, so
objection withdrawn.

> I'll attach a diff for the actual code, so you can check that part out.
> Should've done that the first time :-)

Woulda helped :-)

Just one thing - I'm not sure I like the way the flags look with the two
lines of text below them now - can you do a mockup with the country name
above, and the links below please?

/D



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Remembering the last used mirror
  2007-03-18 20:34 Re: Remembering the last used mirror Dave Page <[email protected]>
  2007-03-18 21:42 ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
  2007-03-19 08:51   ` Re: Remembering the last used mirror Dave Page <[email protected]>
  2007-03-19 09:01     ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
  2007-03-19 09:22       ` Re: Remembering the last used mirror Dave Page <[email protected]>
@ 2007-03-19 15:16         ` Magnus Hagander <[email protected]>
  2007-03-19 15:30           ` Re: Remembering the last used mirror Dave Page <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Magnus Hagander @ 2007-03-19 15:16 UTC (permalink / raw)
  To: Dave Page <[email protected]>; +Cc: pgsql-www

On Mon, Mar 19, 2007 at 09:22:12AM +0000, Dave Page wrote:
> Magnus Hagander wrote:
> > No, then it will not show a default mirror at all - it will look like
> > you had never picked a mirror.
> 
> OK, that's good, and I can't see any of the previous issues, so
> objection withdrawn.
> 
> > I'll attach a diff for the actual code, so you can check that part out.
> > Should've done that the first time :-)
> 
> Woulda helped :-)
> 
> Just one thing - I'm not sure I like the way the flags look with the two
> lines of text below them now - can you do a mockup with the country name
> above, and the links below please?

Kinda like that?

Or should we consider removing the text completely? It's there as an alt
tag on the image for text browsers already, which will also cause a
popup tooltip in IE. IIRC, we can set the title attribute to give such a
tooltip in other browsers..

//Magnus



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Remembering the last used mirror
  2007-03-18 20:34 Re: Remembering the last used mirror Dave Page <[email protected]>
  2007-03-18 21:42 ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
  2007-03-19 08:51   ` Re: Remembering the last used mirror Dave Page <[email protected]>
  2007-03-19 09:01     ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
  2007-03-19 09:22       ` Re: Remembering the last used mirror Dave Page <[email protected]>
  2007-03-19 15:16         ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
@ 2007-03-19 15:30           ` Dave Page <[email protected]>
  2007-03-19 19:49             ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Dave Page @ 2007-03-19 15:30 UTC (permalink / raw)
  To: Magnus Hagander <[email protected]>; +Cc: pgsql-www

Magnus Hagander wrote:
> On Mon, Mar 19, 2007 at 09:22:12AM +0000, Dave Page wrote:
>> Magnus Hagander wrote:
>>> No, then it will not show a default mirror at all - it will look like
>>> you had never picked a mirror.
>> OK, that's good, and I can't see any of the previous issues, so
>> objection withdrawn.
>>
>>> I'll attach a diff for the actual code, so you can check that part out.
>>> Should've done that the first time :-)
>> Woulda helped :-)
>>
>> Just one thing - I'm not sure I like the way the flags look with the two
>> lines of text below them now - can you do a mockup with the country name
>> above, and the links below please?
> 
> Kinda like that?
> 
> Or should we consider removing the text completely? It's there as an alt
> tag on the image for text browsers already, which will also cause a
> popup tooltip in IE. IIRC, we can set the title attribute to give such a
> tooltip in other browsers..

Yeah, I think that would be better.

Regards, Dave



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Remembering the last used mirror
  2007-03-18 20:34 Re: Remembering the last used mirror Dave Page <[email protected]>
  2007-03-18 21:42 ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
  2007-03-19 08:51   ` Re: Remembering the last used mirror Dave Page <[email protected]>
  2007-03-19 09:01     ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
  2007-03-19 09:22       ` Re: Remembering the last used mirror Dave Page <[email protected]>
  2007-03-19 15:16         ` Re: Remembering the last used mirror Magnus Hagander <[email protected]>
  2007-03-19 15:30           ` Re: Remembering the last used mirror Dave Page <[email protected]>
@ 2007-03-19 19:49             ` Magnus Hagander <[email protected]>
  0 siblings, 0 replies; 9+ messages in thread

From: Magnus Hagander @ 2007-03-19 19:49 UTC (permalink / raw)
  To: Dave Page <[email protected]>; +Cc: pgsql-www

Dave Page wrote:
> Magnus Hagander wrote:
>> On Mon, Mar 19, 2007 at 09:22:12AM +0000, Dave Page wrote:
>>> Magnus Hagander wrote:
>>>> No, then it will not show a default mirror at all - it will look like
>>>> you had never picked a mirror.
>>> OK, that's good, and I can't see any of the previous issues, so
>>> objection withdrawn.
>>>
>>>> I'll attach a diff for the actual code, so you can check that part out.
>>>> Should've done that the first time :-)
>>> Woulda helped :-)
>>>
>>> Just one thing - I'm not sure I like the way the flags look with the two
>>> lines of text below them now - can you do a mockup with the country name
>>> above, and the links below please?
>> Kinda like that?
>>
>> Or should we consider removing the text completely? It's there as an alt
>> tag on the image for text browsers already, which will also cause a
>> popup tooltip in IE. IIRC, we can set the title attribute to give such a
>> tooltip in other browsers..
> 
> Yeah, I think that would be better.

Applied. Feel free to rip it apart :-)

//Magnus




^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2007-03-19 19:49 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-03-18 19:41 Remembering the last used mirror Magnus Hagander <[email protected]>
2007-03-18 20:34 Re: Remembering the last used mirror Dave Page <[email protected]>
2007-03-18 21:42 ` Magnus Hagander <[email protected]>
2007-03-19 08:51   ` Dave Page <[email protected]>
2007-03-19 09:01     ` Magnus Hagander <[email protected]>
2007-03-19 09:22       ` Dave Page <[email protected]>
2007-03-19 15:16         ` Magnus Hagander <[email protected]>
2007-03-19 15:30           ` Dave Page <[email protected]>
2007-03-19 19:49             ` Magnus Hagander <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox