*/
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]));
*/
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++) {
settype($bytes, 'integer');
}
- return $bytes . '<small> ' . $type . '</small>';
+ return $bytes . ' ' . $type;
}
/**
* @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');
-
}
/**
* characters are converted to htmlentities first. This will allow
* values like <some@email.address> to be displayed.
* The output is wrapped in <<pre>> and <</pre>> tags.
+ * Since 1.4.2 accepts unlimited number of arguments.
+ * @since 1.4.1
*
* @return void
*/
}
$buffer = ob_get_contents(); // Grab the print_r output
ob_end_clean(); // Silently discard the output & stop buffering
- print '<pre>';
+ print '<div align="left"><pre>';
print htmlentities($buffer);
- print '</pre>';
+ print '</pre></div>';
}
/**
* 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
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);
}
* @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
$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);
}
$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);
}
$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);
}
return strtoupper($string);
}
$PHP_SELF = php_self();
-?>
+?>
\ No newline at end of file