This code below converts a users input and colors they select into random colors ouput in UBB format.
My question is, is there any way to tweak this to make it flow better, more secure, etc. I want to eventually donate the completed source code to a friend so I want it to be pretty secure.
Thanks 🙂
//start the every letter color script
function everyletter($message, $color){
//if server is not running PHP 5.0.0 or greater you need this next part
if(!function_exists('str_split')) {
function str_split($string) {
$chars = array();
for($i=0;$i<strlen($string);$i++) {
$chars[] = $string{$i};
}
return $chars;
}
}
//end PHP5 function replication
//*****************************
//start conversion and display
$split_message = str_split($message);
$num = count($split_message);
$last_color = "blue";
for($i=0; $i<$num; $i++){
$select_color = $color[array_rand($color)];
while($select_color == $last_color){ $select_color = $color[array_rand($color)]; } //make sure colors dont repeat
if($split_message[$i] == " "){ //if message is a space
echo " ";
$last_color = $select_color;
} else { // other half
if($select_color == "black"){ //if random is black
$split_message[$i] = stripslashes($split_message[$i]);
if($split_message[$i] !== ""){
echo $split_message[$i];
$last_color = $select_color;
} //end if
} else { //else not black
$split_message[$i] = stripslashes($split_message[$i]);
if($split_message[$i] !== ""){
echo "[".$select_color."]".$split_message[$i]."[/".$select_color."]";
$last_color = $select_color;
} //end if blank
}// end if
}//end if
}// end for message
echo "\n\nPowered by Spechal.com";
} // end everyletter function