Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- source.txt 2011-07-16 02:16:58.000000000 +0200
- +++ source.txt 2011-07-16 02:08:46.129572000 +0200
- @@ -24,6 +24,11 @@
- if (!class_exists('SQLite3'))
- die("This software requires the SQLite3 PHP extension, and it can't be found on this system!");
- +// Can't be call directly
- +if ( basename($_SERVER['SCRIPT_FILENAME']) == basename(__FILE__) ) {
- + header('Location: index.php');
- +}
- +
- // Config and data file locations
- if (file_exists(__DIR__ . '/config.php'))
- @@ -32,7 +37,7 @@
- }
- if (!defined('ROOT_DIR'))
- - define('ROOT_DIR', __DIR__);
- + define('ROOT_DIR', dirname($_SERVER['SCRIPT_FILENAME']));
- if (!defined('CONFIG_FILE')) define('CONFIG_FILE', ROOT_DIR . '/vvb.ini');
- if (!defined('ARTICLES_DB_FILE')) define('ARTICLES_DB_FILE', ROOT_DIR . '/articles.db');
- @@ -43,6 +48,7 @@
- {
- // Automagic URL discover
- $path = substr(ROOT_DIR, strlen($_SERVER['DOCUMENT_ROOT']));
- + $path = (substr($path, 0, 1) != '/') ? '/' . $path : $path;
- $path = (substr($path, -1) != '/') ? $path . '/' : $path;
- define('LOCAL_URL', 'http' . (!empty($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $path);
- }
- @@ -50,7 +56,7 @@
- if (!defined('LOCAL_URI'))
- {
- // filename
- - define('LOCAL_URI', (basename(__FILE__) == 'index.php' ? '' : basename(__FILE__)) . '?');
- + define('LOCAL_URI', (basename($_SERVER['SCRIPT_FILENAME']) == 'index.php' ? '' : basename($_SERVER['SCRIPT_FILENAME'])) . '?');
- }
- if (!function_exists('__'))
- @@ -574,16 +576,20 @@
- $url = $url['scheme'] . '://' . $url['host'] . $url['path'];
- $filename = substr(sha1($url), -8) . '.' . substr(preg_replace('![^\w\d_.-]!', '', $filename), -64);
- - $ok = @copy($url, MEDIA_DIR . '/' . $filename);
- -
- - if ($ok)
- - {
- - $content = str_replace($m[0], $m[1] . '="media/'.$filename.'" data-original-source="'.$url.'"', $content);
- - }
- - else
- - {
- - $content = str_replace($m[0], $m[1] . '="'.$url.'"', $content);
- - }
- + $dest = MEDIA_DIR . '/' . $filename;
- +
- + if ( ! file_exists($dest) ) {
- + try {
- + $distant = file_get_contents($url);
- + if ( file_put_contents($dest, $distant)) {
- + $content = str_replace($m[0], $m[1] . '="media/'.$filename.'" data-original-source="'.$url, $content);
- + } else {
- + $content = str_replace($m[0], $m[1] . '="'.$url.'"', $content);
- + }
- + } catch ( Exception $e ) {
- + // Error 404...
- + $content = str_replace($m[0], $m[1] . '="'.$url.'"', $content);
- + }
- + }
- }
- return $content;
- @@ -826,6 +832,7 @@
- * { margin: 0; padding: 0; }
- body { font-family:"Trebuchet MS",Verdana,Arial,Helvetica,sans-serif; background-color: #3E4B50; padding: 1%; color: #000; }
- img { max-width: 100%; height: auto; }
- + pre { width: 100%; overflow: auto; }
- .header h1 { text-shadow: 2px 2px 2px #000; }
- .header h1 a { text-decoration: none; color: #eee; }
- .header { padding: 1% 3%; color: #eee; margin: 0 10%; border-bottom: 1px solid #aaa; background: #6A6A6A; }
- @@ -856,4 +863,4 @@
- .result h3 a { color: darkblue; text-decoration: none; text-shadow: 1px 1px 1px #fff; }';
- }
- -?>
- \ Pas de fin de ligne à la fin du fichier.
- +?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement