Просмотр исходного кода

various fixes:
- changing default formatter option to plain text to make upgrading from
0.19 Alpha smoother
- fixing translation message change in bootstrap templates
- adjusting how image uploads are displayed in bootstrap templates

El RIDO 11 лет назад
Родитель
Сommit
a41d0ca4dd
5 измененных файлов с 35 добавлено и 73 удалено
  1. 2 2
      cfg/conf.ini
  2. 1 0
      css/bootstrap/zerobin.css
  3. 30 69
      lib/zerobin.php
  4. 1 1
      tpl/bootstrap-compact.html
  5. 1 1
      tpl/bootstrap.html

+ 2 - 2
cfg/conf.ini

@@ -23,9 +23,9 @@ fileupload = false
 ; preselect the burn-after-reading feature, defaults to false
 ; preselect the burn-after-reading feature, defaults to false
 burnafterreadingselected = false
 burnafterreadingselected = false
 
 
-; which display mode to preselect by default, defaults to "syntaxhighlighting"
+; which display mode to preselect by default, defaults to "plaintext"
 ; make sure the value exists in [formatter_options]
 ; make sure the value exists in [formatter_options]
-defaultformatter = "syntaxhighlighting"
+defaultformatter = "plaintext"
 
 
 ; (optional) set a syntax highlighting theme, as found in css/prettify/
 ; (optional) set a syntax highlighting theme, as found in css/prettify/
 ; syntaxhighlightingtheme = "sons-of-obsidian"
 ; syntaxhighlightingtheme = "sons-of-obsidian"

+ 1 - 0
css/bootstrap/zerobin.css

@@ -35,6 +35,7 @@ body.navbar-spacing {
 #image img {
 #image img {
 	max-width: 100%;
 	max-width: 100%;
 	height: auto;
 	height: auto;
+	margin-bottom: 20px;
 }
 }
 
 
 #deletelink {
 #deletelink {

+ 30 - 69
lib/zerobin.php

@@ -232,31 +232,25 @@ class zerobin
                 $ipKey = $header;
                 $ipKey = $header;
             }
             }
         }
         }
-        if (!trafficlimiter::canPass($_SERVER[$ipKey]))
-        {
-            $this->_return_message(
-                1,
-                i18n::_(
-                    'Please wait %d seconds between each post.',
-                    $this->_conf['traffic']['limit']
-                )
-            );
-            return;
-        }
+        if (!trafficlimiter::canPass($_SERVER[$ipKey])) return $this->_return_message(
+            1,
+            i18n::_(
+                'Please wait %d seconds between each post.',
+                $this->_conf['traffic']['limit']
+            )
+        );
 
 
         // Make sure content is not too big.
         // Make sure content is not too big.
         $sizelimit = (int) $this->_getMainConfig('sizelimit', 2097152);
         $sizelimit = (int) $this->_getMainConfig('sizelimit', 2097152);
-        if (strlen($data) + strlen($attachment) + strlen($attachmentname) > $sizelimit)
-        {
-            $this->_return_message(
-                1,
-                i18n::_(
-                    'Paste is limited to %s of encrypted data.',
-                    filter::size_humanreadable($sizelimit)
-                )
-            );
-            return;
-        }
+        if (
+            strlen($data) + strlen($attachment) + strlen($attachmentname) > $sizelimit
+        ) return $this->_return_message(
+            1,
+            i18n::_(
+                'Paste is limited to %s of encrypted data.',
+                filter::size_humanreadable($sizelimit)
+            )
+        );
 
 
         // Make sure format is correct.
         // Make sure format is correct.
         if (!sjcl::isValid($data)) return $this->_return_message(1, 'Invalid data.');
         if (!sjcl::isValid($data)) return $this->_return_message(1, 'Invalid data.');
@@ -268,7 +262,7 @@ class zerobin
                 !$this->_getMainConfig('fileupload', false) ||
                 !$this->_getMainConfig('fileupload', false) ||
                 !sjcl::isValid($attachment) ||
                 !sjcl::isValid($attachment) ||
                 !($has_attachmentname && sjcl::isValid($attachmentname))
                 !($has_attachmentname && sjcl::isValid($attachmentname))
-            ) $this->_return_message(1, 'Invalid attachment.');
+            ) return $this->_return_message(1, 'Invalid attachment.');
         }
         }
 
 
         // Read additional meta-information.
         // Read additional meta-information.
@@ -321,7 +315,7 @@ class zerobin
             $formatter = $_POST['formatter'];
             $formatter = $_POST['formatter'];
             if (!array_key_exists($formatter, $this->_conf['formatter_options']))
             if (!array_key_exists($formatter, $this->_conf['formatter_options']))
             {
             {
-                $formatter = $this->_getMainConfig('defaultformatter', 'syntaxhighlighting');
+                $formatter = $this->_getMainConfig('defaultformatter', 'plaintext');
             }
             }
             $meta['formatter'] = $formatter;
             $meta['formatter'] = $formatter;
         }
         }
@@ -354,11 +348,7 @@ class zerobin
             }
             }
         }
         }
 
 
-        if ($error)
-        {
-            $this->_return_message(1, 'Invalid data.');
-            return;
-        }
+        if ($error) return $this->_return_message(1, 'Invalid data.');
 
 
         // Add post date to meta.
         // Add post date to meta.
         $meta['postdate'] = time();
         $meta['postdate'] = time();
@@ -383,11 +373,7 @@ class zerobin
             if (
             if (
                 !filter::is_valid_paste_id($pasteid) ||
                 !filter::is_valid_paste_id($pasteid) ||
                 !filter::is_valid_paste_id($parentid)
                 !filter::is_valid_paste_id($parentid)
-            )
-            {
-                $this->_return_message(1, 'Invalid data.');
-                return;
-            }
+            ) return $this->_return_message(1, 'Invalid data.');
 
 
             // Comments do not expire (it's the paste that expires)
             // Comments do not expire (it's the paste that expires)
             unset($storage['expire_date']);
             unset($storage['expire_date']);
@@ -396,43 +382,26 @@ class zerobin
             // Make sure paste exists.
             // Make sure paste exists.
             if (
             if (
                 !$this->_model()->exists($pasteid)
                 !$this->_model()->exists($pasteid)
-            )
-            {
-                $this->_return_message(1, 'Invalid data.');
-                return;
-            }
+            ) return $this->_return_message(1, 'Invalid data.');
 
 
             // Make sure the discussion is opened in this paste.
             // Make sure the discussion is opened in this paste.
             $paste = $this->_model()->read($pasteid);
             $paste = $this->_model()->read($pasteid);
             if (
             if (
                 !$paste->meta->opendiscussion
                 !$paste->meta->opendiscussion
-            )
-            {
-                $this->_return_message(1, 'Invalid data.');
-                return;
-            }
+            ) return $this->_return_message(1, 'Invalid data.');
 
 
             // Check for improbable collision.
             // Check for improbable collision.
             if (
             if (
                 $this->_model()->existsComment($pasteid, $parentid, $dataid)
                 $this->_model()->existsComment($pasteid, $parentid, $dataid)
-            )
-            {
-                $this->_return_message(1, 'You are unlucky. Try again.');
-                return;
-            }
+            ) return $this->_return_message(1, 'You are unlucky. Try again.');
 
 
             // New comment
             // New comment
             if (
             if (
                 $this->_model()->createComment($pasteid, $parentid, $dataid, $storage) === false
                 $this->_model()->createComment($pasteid, $parentid, $dataid, $storage) === false
-            )
-            {
-                $this->_return_message(1, 'Error saving comment. Sorry.');
-                return;
-            }
+            ) return $this->_return_message(1, 'Error saving comment. Sorry.');
 
 
             // 0 = no error
             // 0 = no error
-            $this->_return_message(0, $dataid);
-            return;
+            return $this->_return_message(0, $dataid);
         }
         }
         // The user posts a standard paste.
         // The user posts a standard paste.
         else
         else
@@ -440,11 +409,7 @@ class zerobin
             // Check for improbable collision.
             // Check for improbable collision.
             if (
             if (
                 $this->_model()->exists($dataid)
                 $this->_model()->exists($dataid)
-            )
-            {
-                $this->_return_message(1, 'You are unlucky. Try again.');
-                return;
-            }
+            ) return $this->_return_message(1, 'You are unlucky. Try again.');
 
 
             // Add attachment and its name, if one was sent
             // Add attachment and its name, if one was sent
             if ($has_attachment) $storage['attachment'] = $attachment;
             if ($has_attachment) $storage['attachment'] = $attachment;
@@ -453,10 +418,7 @@ class zerobin
             // New paste
             // New paste
             if (
             if (
                 $this->_model()->create($dataid, $storage) === false
                 $this->_model()->create($dataid, $storage) === false
-            ) {
-                $this->_return_message(1, 'Error saving paste. Sorry.');
-                return;
-            }
+            ) return $this->_return_message(1, 'Error saving paste. Sorry.');
 
 
             // Generate the "delete" token.
             // Generate the "delete" token.
             // The token is the hmac of the pasteid signed with the server salt.
             // The token is the hmac of the pasteid signed with the server salt.
@@ -464,8 +426,7 @@ class zerobin
             $deletetoken = hash_hmac('sha1', $dataid, serversalt::get());
             $deletetoken = hash_hmac('sha1', $dataid, serversalt::get());
 
 
             // 0 = no error
             // 0 = no error
-            $this->_return_message(0, $dataid, array('deletetoken' => $deletetoken));
-            return;
+            return $this->_return_message(0, $dataid, array('deletetoken' => $deletetoken));
         }
         }
     }
     }
 
 
@@ -609,7 +570,7 @@ class zerobin
                     }
                     }
                     else
                     else
                     {
                     {
-                        $paste->meta->formatter = $this->_getMainConfig('defaultformatter', 'syntaxhighlighting');
+                        $paste->meta->formatter = $this->_getMainConfig('defaultformatter', 'plaintext');
                     }
                     }
                 }
                 }
 
 
@@ -680,7 +641,7 @@ class zerobin
         $page->assign('SYNTAXHIGHLIGHTING', array_key_exists('syntaxhighlighting', $formatters));
         $page->assign('SYNTAXHIGHLIGHTING', array_key_exists('syntaxhighlighting', $formatters));
         $page->assign('SYNTAXHIGHLIGHTINGTHEME', $this->_getMainConfig('syntaxhighlightingtheme', ''));
         $page->assign('SYNTAXHIGHLIGHTINGTHEME', $this->_getMainConfig('syntaxhighlightingtheme', ''));
         $page->assign('FORMATTER', $formatters);
         $page->assign('FORMATTER', $formatters);
-        $page->assign('FORMATTERDEFAULT', $this->_getMainConfig('defaultformatter', 'syntaxhighlighting'));
+        $page->assign('FORMATTERDEFAULT', $this->_getMainConfig('defaultformatter', 'plaintext'));
         $page->assign('NOTICE', i18n::_($this->_getMainConfig('notice', '')));
         $page->assign('NOTICE', i18n::_($this->_getMainConfig('notice', '')));
         $page->assign('BURNAFTERREADINGSELECTED', $this->_getMainConfig('burnafterreadingselected', false));
         $page->assign('BURNAFTERREADINGSELECTED', $this->_getMainConfig('burnafterreadingselected', false));
         $page->assign('PASSWORD', $this->_getMainConfig('password', true));
         $page->assign('PASSWORD', $this->_getMainConfig('password', true));

+ 1 - 1
tpl/bootstrap-compact.html

@@ -103,7 +103,7 @@
 							</div>
 							</div>
 						</li>{/if}{if="$FILEUPLOAD"}
 						</li>{/if}{if="$FILEUPLOAD"}
 						<li id="attach" class="hidden dropdown">
 						<li id="attach" class="hidden dropdown">
-							<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{function="t('Attach a file:')"} <span class="caret"></span></a>
+							<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{function="t('Attach a file')"} <span class="caret"></span></a>
 							<ul class="dropdown-menu">
 							<ul class="dropdown-menu">
 								<li id="filewrap">
 								<li id="filewrap">
 									<div>
 									<div>

+ 1 - 1
tpl/bootstrap.html

@@ -86,7 +86,7 @@
 							</div>
 							</div>
 						</li>{/if}{if="$FILEUPLOAD"}
 						</li>{/if}{if="$FILEUPLOAD"}
 						<li id="attach" class="hidden dropdown">
 						<li id="attach" class="hidden dropdown">
-							<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{function="t('Attach a file:')"} <span class="caret"></span></a>
+							<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{function="t('Attach a file')"} <span class="caret"></span></a>
 							<ul class="dropdown-menu">
 							<ul class="dropdown-menu">
 								<li id="filewrap">
 								<li id="filewrap">
 									<div>
 									<div>