// Count the number of occurances of $needle are in $haystack.
//*************************************************************************
function countCharInString($haystack, $needle) {
// Count the number of occurances of $needle are in $haystack.
//*************************************************************************
function countCharInString($haystack, $needle) {
// of the $haystack is reached. $needle is a single character
//*************************************************************************
function readShortMailboxName($haystack, $needle) {
// of the $haystack is reached. $needle is a single character
//*************************************************************************
function readShortMailboxName($haystack, $needle) {
// of the $haystack is reached. $needle is a single character
//*************************************************************************
function readMailboxParent($haystack, $needle) {
// of the $haystack is reached. $needle is a single character
//*************************************************************************
function readMailboxParent($haystack, $needle) {
ereg("^(.+)$needle([^$needle]+)$needle?$", $haystack, $regs);
return $regs[1];
}
// Searches for the next position in a string minus white space
function next_pos_minus_white ($haystack, $pos) {
ereg("^(.+)$needle([^$needle]+)$needle?$", $haystack, $regs);
return $regs[1];
}
// Searches for the next position in a string minus white space
function next_pos_minus_white ($haystack, $pos) {
substr($haystack, $pos, 1) == "\t" ||
substr($haystack, $pos, 1) == "\n" ||
substr($haystack, $pos, 1) == "\r") {
substr($haystack, $pos, 1) == "\t" ||
substr($haystack, $pos, 1) == "\n" ||
substr($haystack, $pos, 1) == "\r") {
function sqWordWrap(&$line, $wrap) {
preg_match("/^([\s>]*)([^\s>].*)?$/", $line, $regs);
$beginning_spaces = $regs[1];
function sqWordWrap(&$line, $wrap) {
preg_match("/^([\s>]*)([^\s>].*)?$/", $line, $regs);
$beginning_spaces = $regs[1];
- $text = str_replace(" ", "", $text);
- $text = ereg_replace('"[^"]*"', "", $text);
- $text = ereg_replace("\([^\)]*\)", "", $text);
- $text = str_replace(",", ";", $text);
- $array = explode(";", $text);
+ $text = str_replace(' ', '', $text);
+ $text = ereg_replace('"[^"]*"', '', $text);
+ $text = ereg_replace("\([^\)]*\)", '', $text);
+ $text = str_replace(',', ';', $text);
+ $array = explode(';', $text);
- $array[$i] = eregi_replace ("^.*[<]", "", $array[$i]);
- $array[$i] = eregi_replace ("[>].*$", "", $array[$i]);
+ $array[$i] = eregi_replace ("^.*[<]", '', $array[$i]);
+ $array[$i] = eregi_replace ("[>].*$", '', $array[$i]);
/** Returns a line of comma separated email addresses from an array **/
function getLineOfAddrs($array) {
if (is_array($array)) {
/** Returns a line of comma separated email addresses from an array **/
function getLineOfAddrs($array) {
if (is_array($array)) {
- $to_line = implode(", ", $array);
- $to_line = trim(ereg_replace(",,+", ",", $to_line));
+ $to_line = implode(', ', $array);
+ $to_line = trim(ereg_replace(',,+', ',', $to_line));
- $box = substr($mailbox, strrpos($mailbox, " ")+1, strlen($mailbox));
+ $box = substr($mailbox, strrpos($mailbox, ' ')+1, strlen($mailbox));
$path = substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'));
// Check if this is a HTTPS or regular HTTP request
$path = substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'));
// Check if this is a HTTPS or regular HTTP request
if (! strstr($host, ':'))
{
if (isset($SERVER_PORT)) {
if (! strstr($host, ':'))
{
if (isset($SERVER_PORT)) {
- if (($SERVER_PORT != 80 && $proto == "http://")
- || ($SERVER_PORT != 443 && $proto == "https://")) {
+ if (($SERVER_PORT != 80 && $proto == 'http://')
+ || ($SERVER_PORT != 443 && $proto == 'https://')) {
// stored in a cookie.
function OneTimePadEncrypt ($string, $epad) {
$pad = base64_decode($epad);
// stored in a cookie.
function OneTimePadEncrypt ($string, $epad) {
$pad = base64_decode($epad);
function OneTimePadDecrypt ($string, $epad) {
$pad = base64_decode($epad);
$encrypted = base64_decode ($string);
function OneTimePadDecrypt ($string, $epad) {
$pad = base64_decode($epad);
$encrypted = base64_decode ($string);
for ($i = 0; $i < strlen ($encrypted); $i++) {
$decrypted .= chr (ord($encrypted[$i]) ^ ord($pad[$i]));
}
for ($i = 0; $i < strlen ($encrypted); $i++) {
$decrypted .= chr (ord($encrypted[$i]) ^ ord($pad[$i]));
}
for ($i = 0; $i < $length; $i++) {
$pad .= chr(mt_rand(0,255));
}
for ($i = 0; $i < $length; $i++) {
$pad .= chr(mt_rand(0,255));
}