public function mylivechat::MakeArray in My Live Chat 6
Same name and namespace in other branches
- 7 mylivechat.php \MyLiveChat::MakeArray()
1 call to mylivechat::MakeArray()
File
- ./
mylivechat.php, line 229 - MyLiveChat module for Drupal
Class
- mylivechat
- @file MyLiveChat module for Drupal
Code
public function MakeArray($str, $random) {
$len = pow(2, floor(log(strlen($str), 2)) + 1) + 8;
if ($len < 32) {
$len = 32;
}
$arr = array();
$strarr = str_split($str);
if ($random == true) {
for ($i = 0; $i < $len; $i++) {
$arr[] = ord($strarr[rand() % strlen($str)]);
}
$start = 1 + rand() % ($len - strlen($str) - 2);
for ($i = 0; $i < strlen($str); $i++) {
$arr[$start + $i] = ord($strarr[$i]);
}
$arr[$start - 1] = 0;
$arr[$start + strlen($str)] = 0;
}
else {
for ($i = 0; $i < $len; $i++) {
$arr[] = ord($strarr[$i % strlen($str)]);
}
}
return $arr;
}