]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #126 from Alkarex/Milliseconds
authorSébastien SAUVAGE <sebsauvage@sebsauvage.net>
Tue, 24 Sep 2013 09:02:33 +0000 (02:02 -0700)
committerSébastien SAUVAGE <sebsauvage@sebsauvage.net>
Tue, 24 Sep 2013 09:02:33 +0000 (02:02 -0700)
Import: add compatibility for milliseconds in NETSCAPE-Bookmark

1  2 
index.php

diff --combined index.php
index 2154c063ad4b9e1449005966b5e1875494718031,b65bfb7c9fc25772aa6dabeedf5a586f31473810..b402eba9b2f7f006441bd8b65bc19293bf778d70
+++ b/index.php
@@@ -566,7 -566,7 +566,7 @@@ function getHTTP($url,$timeout=30
  {
      try
      {
 -        $options = array('http'=>array('method'=>'GET','timeout' => $timeout)); // Force network timeout
 +        $options = array('http'=>array('method'=>'GET','timeout' => $timeout, 'user_agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:23.0) Gecko/20100101 Firefox/23.0')); // Force network timeout
          $context = stream_context_create($options);
          $data=file_get_contents($url,false,$context,-1, 4000000); // We download at most 4 Mb from source.
          if (!$data) { return array('HTTP Error',array(),''); }
@@@ -1695,7 -1695,11 +1695,11 @@@ function importFile(
                  {
                      $attr=$m[1]; $value=$m[2];
                      if ($attr=='HREF') $link['url']=html_entity_decode($value,ENT_QUOTES,'UTF-8');
-                     elseif ($attr=='ADD_DATE') $raw_add_date=intval($value);
+                     elseif ($attr=='ADD_DATE')
+                     {
+                         $raw_add_date=intval($value);
+                         if ($raw_add_date>30000000000) $raw_add_date/=1000;   //If larger than year 2920, then was likely stored in milliseconds instead of seconds
+                     }
                      elseif ($attr=='PRIVATE') $link['private']=($value=='0'?0:1);
                      elseif ($attr=='TAGS') $link['tags']=html_entity_decode(str_replace(',',' ',$value),ENT_QUOTES,'UTF-8');
                  }
@@@ -2440,4 -2444,4 +2444,4 @@@ if (isset($_SERVER["QUERY_STRING"]) && 
  if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'ws=')) { processWS(); exit; } // Webservices (for jQuery/jQueryUI)
  if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE'];
  renderPage();
 -?>
 +?>