content disposition rfc
[squirrelmail.git] / functions / strings.php
index dab833d45b8f53c34581a04bcd962fd9bdcd6f66..dca58dec0d6a842b55c6d207976b34eb6a8575e6 100644 (file)
@@ -588,6 +588,16 @@ function get_location () {
  */
 function OneTimePadEncrypt ($string, $epad) {
     $pad = base64_decode($epad);
+
+    if (strlen($pad)>0) {
+        // make sure that pad is longer than string
+        while (strlen($string)>strlen($pad)) {
+            $pad.=$pad;
+        }
+    } else {
+        // FIXME: what should we do when $epad is not base64 encoded or empty.
+    }
+
     $encrypted = '';
     for ($i = 0; $i < strlen ($string); $i++) {
         $encrypted .= chr (ord($string[$i]) ^ ord($pad[$i]));
@@ -608,6 +618,16 @@ function OneTimePadEncrypt ($string, $epad) {
  */
 function OneTimePadDecrypt ($string, $epad) {
     $pad = base64_decode($epad);
+
+    if (strlen($pad)>0) {
+        // make sure that pad is longer than string
+        while (strlen($string)>strlen($pad)) {
+            $pad.=$pad;
+        }
+    } else {
+        // FIXME: what should we do when $epad is not base64 encoded or empty.
+    }
+
     $encrypted = base64_decode ($string);
     $decrypted = '';
     for ($i = 0; $i < strlen ($encrypted); $i++) {
@@ -735,7 +755,7 @@ function show_readable_size($bytes) {
         settype($bytes, 'integer');
     }
 
-    return $bytes . '<small>&nbsp;' . $type . '</small>';
+    return $bytes . '&nbsp;' . $type;
 }
 
 /**
@@ -817,35 +837,31 @@ function TrimArray(&$array) {
  * @param string text the link text, default "Compose"
  * @return string a link to the compose page
  */
-function makeComposeLink($url, $text = null, $target='')
-{
-    global $compose_new_win,$javascript_on;
+function makeComposeLink($url, $text = null, $target='') {
+    global $compose_new_win,$javascript_on, $compose_width, $compose_height;
 
     if(!$text) {
         $text = _("Compose");
     }
 
-
     // if not using "compose in new window", make
     // regular link and be done with it
     if($compose_new_win != '1') {
         return makeInternalLink($url, $text, $target);
     }
 
-
     // build the compose in new window link...
 
 
     // if javascript is on, use onclick event to handle it
     if($javascript_on) {
         sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
-        return '<a href="javascript:void(0)" onclick="comp_in_new(\''.$base_uri.$url.'\')">'. $text.'</a>';
+        $compuri = $base_uri.$url;
+        return "<a href=\"javascript:void(0)\" onclick=\"comp_in_new('$compuri','$compose_width','$compose_height')\">$text</a>";
     }
 
-
     // otherwise, just open new window using regular HTML
     return makeInternalLink($url, $text, '_blank');
-
 }
 
 /**
@@ -859,6 +875,7 @@ function makeComposeLink($url, $text = null, $target='')
  * The output is wrapped in <<pre>> and <</pre>> tags.
  * Since 1.4.2 accepts unlimited number of arguments.
  * @since 1.4.1
+ *
  * @return void
  */
 function sm_print_r() {
@@ -1094,13 +1111,13 @@ function sq_mb_list_encodings() {
  * Function returns number of characters in string.
  *
  * Returned number might be different from number of bytes in string,
- * if $charset is multibyte charset. Detection depends on mbstring 
+ * if $charset is multibyte charset. Detection depends on mbstring
  * functions. If mbstring does not support tested multibyte charset,
- * vanilla string length function is used. 
+ * vanilla string length function is used.
  * @param string $str string
  * @param string $charset charset
  * @since 1.5.1
- * @return integer number of characters in string 
+ * @return integer number of characters in string
  */
 function sq_strlen($str, $charset=''){
     // default option
@@ -1123,7 +1140,7 @@ function sq_strlen($str, $charset=''){
     if (in_array($charset,$aList_of_mb_charsets) && in_array($charset,sq_mb_list_encodings())) {
         $real_length = mb_strlen($str,$charset);
     } else {
-        // own strlen detection code is removed because missing strpos, 
+        // own strlen detection code is removed because missing strpos,
         // strtoupper and substr implementations break string wrapping.
         $real_length=strlen($str);
     }
@@ -1137,7 +1154,7 @@ function sq_strlen($str, $charset=''){
  * @param string $string original string
  * @param integer $width padded string width
  * @param string $pad padding symbols
- * @param integer $padtype padding type 
+ * @param integer $padtype padding type
  *  (internal php defines, see str_pad() description)
  * @param string $charset charset used in original string
  * @return string padded string
@@ -1183,7 +1200,7 @@ function sq_substr($string,$start,$length,$charset='auto') {
         $charset=$default_charset;
     }
     $charset = strtolower($charset);
-    if (function_exists('mb_internal_encoding') && 
+    if (function_exists('mb_internal_encoding') &&
         in_array($charset,sq_mb_list_encodings())) {
         return mb_substr($string,$start,$length,$charset);
     }
@@ -1213,7 +1230,7 @@ function sq_strpos($haystack,$needle,$offset,$charset='auto') {
         $charset=$default_charset;
     }
     $charset = strtolower($charset);
-    if (function_exists('mb_internal_encoding') && 
+    if (function_exists('mb_internal_encoding') &&
         in_array($charset,sq_mb_list_encodings())) {
         return mb_strpos($haystack,$needle,$offset,$charset);
     }
@@ -1241,7 +1258,7 @@ function sq_strtoupper($string,$charset='auto') {
         $charset=$default_charset;
     }
     $charset = strtolower($charset);
-    if (function_exists('mb_strtoupper') && 
+    if (function_exists('mb_strtoupper') &&
         in_array($charset,sq_mb_list_encodings())) {
         return mb_strtoupper($string,$charset);
     }
@@ -1251,4 +1268,4 @@ function sq_strtoupper($string,$charset='auto') {
     return strtoupper($string);
 }
 $PHP_SELF = php_self();
-?>
+?>
\ No newline at end of file