Advertisement
Guest User

VroumVroumBlog 0.2.2 patch

a guest
Jul 15th, 2011
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.33 KB | None | 0 0
  1. --- source.txt  2011-07-16 02:16:58.000000000 +0200
  2. +++ source.txt  2011-07-16 02:08:46.129572000 +0200
  3. @@ -24,6 +24,11 @@
  4.  if (!class_exists('SQLite3'))
  5.      die("This software requires the SQLite3 PHP extension, and it can't be found on this system!");
  6.  
  7. +// Can't be call directly
  8. +if ( basename($_SERVER['SCRIPT_FILENAME']) == basename(__FILE__) ) {
  9. +   header('Location: index.php');
  10. +}
  11. +
  12.  // Config and data file locations
  13.  
  14.  if (file_exists(__DIR__ . '/config.php'))
  15. @@ -32,7 +37,7 @@
  16.  }
  17.  
  18.  if (!defined('ROOT_DIR'))
  19. -    define('ROOT_DIR', __DIR__);
  20. +    define('ROOT_DIR', dirname($_SERVER['SCRIPT_FILENAME']));
  21.  
  22.  if (!defined('CONFIG_FILE'))        define('CONFIG_FILE', ROOT_DIR . '/vvb.ini');
  23.  if (!defined('ARTICLES_DB_FILE'))   define('ARTICLES_DB_FILE', ROOT_DIR . '/articles.db');
  24. @@ -43,6 +48,7 @@
  25.  {
  26.      // Automagic URL discover
  27.      $path = substr(ROOT_DIR, strlen($_SERVER['DOCUMENT_ROOT']));
  28. +    $path = (substr($path, 0, 1) != '/') ? '/' . $path : $path;
  29.      $path = (substr($path, -1) != '/') ? $path . '/' : $path;
  30.      define('LOCAL_URL', 'http' . (!empty($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $path);
  31.  }
  32. @@ -50,7 +56,7 @@
  33.  if (!defined('LOCAL_URI'))
  34.  {
  35.      // filename
  36. -    define('LOCAL_URI', (basename(__FILE__) == 'index.php' ? '' : basename(__FILE__)) . '?');
  37. +    define('LOCAL_URI', (basename($_SERVER['SCRIPT_FILENAME']) == 'index.php' ? '' : basename($_SERVER['SCRIPT_FILENAME'])) . '?');
  38.  }
  39.  
  40.  if (!function_exists('__'))
  41. @@ -574,16 +576,20 @@
  42.              $url = $url['scheme'] . '://' . $url['host'] . $url['path'];
  43.  
  44.              $filename = substr(sha1($url), -8) . '.' . substr(preg_replace('![^\w\d_.-]!', '', $filename), -64);
  45. -            $ok = @copy($url, MEDIA_DIR . '/' . $filename);
  46. -
  47. -            if ($ok)
  48. -            {
  49. -                $content = str_replace($m[0], $m[1] . '="media/'.$filename.'" data-original-source="'.$url.'"', $content);
  50. -            }
  51. -            else
  52. -            {
  53. -                $content = str_replace($m[0], $m[1] . '="'.$url.'"', $content);
  54. -            }
  55. +            $dest = MEDIA_DIR . '/' . $filename;
  56. +            
  57. +            if ( ! file_exists($dest) ) {
  58. +               try {
  59. +                   $distant = file_get_contents($url);
  60. +                   if ( file_put_contents($dest, $distant)) {
  61. +                       $content = str_replace($m[0], $m[1] . '="media/'.$filename.'" data-original-source="'.$url, $content);
  62. +                   } else {
  63. +                       $content = str_replace($m[0], $m[1] . '="'.$url.'"', $content);
  64. +                   }
  65. +               } catch ( Exception $e ) {
  66. +                   // Error 404...
  67. +                   $content = str_replace($m[0], $m[1] . '="'.$url.'"', $content);
  68. +               }
  69. +           }
  70.          }
  71.  
  72.          return $content;
  73. @@ -826,6 +832,7 @@
  74.      * { margin: 0; padding: 0; }
  75.      body { font-family:"Trebuchet MS",Verdana,Arial,Helvetica,sans-serif; background-color: #3E4B50; padding: 1%; color: #000; }
  76.      img { max-width: 100%; height: auto; }
  77. +    pre { width: 100%; overflow: auto; }
  78.      .header h1 { text-shadow: 2px 2px 2px #000; }
  79.      .header h1 a { text-decoration: none; color: #eee; }
  80.      .header { padding: 1% 3%; color: #eee; margin: 0 10%; border-bottom: 1px solid #aaa; background: #6A6A6A; }
  81. @@ -856,4 +863,4 @@
  82.      .result h3 a { color: darkblue; text-decoration: none; text-shadow: 1px 1px 1px #fff; }';
  83.  }
  84.  
  85. -?>
  86. \ Pas de fin de ligne à la fin du fichier.
  87. +?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement