Not really sure where these are coming from, but they’re being produced
after I try to encode something,
[code]
things like manufacterer’s
turn into manufacturer�s
and degree’s for fahrenheit/celsius
113° F (45° C) have that A after
them. Evert time I hit execute after,
it adds even more
113���° F (45���° C)
What the hell happened? This is driving me bat**** trying to convert all
this to htmlentities per case….
Here’s my coding.
[code=php]
<?php
// Global defines
define(‘VERSION’, ‘2.1e’);
define(‘SALT’, $salt);
# var list
$sp ='<x style=”margin:5%” />’;
$salt = ‘o_0 Neko%$Mata 2051’;
function encrypt($text) {
return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, SALT, $text,
MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB),
MCRYPT_RAND))));
}
function decrypt($text) {
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, SALT, base64_decode($text),
MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB),
MCRYPT_RAND)));
}
function fixoutput($str){
$good[] = 9; #tab
$good[] = 10; #nl
$good[] = 13; #cr
for($a=32;$a<127;$a++){
$good[] = $a;
}
$len = strlen($str);
for($b=0;$b < $len+1; $b++){
if(in_array(ord($str[$b]), $good)){
$newstr .= $str[$b];
}//fi
}//rof
return $newstr;
}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>MCrypt v<?=VERSION ?></title>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<meta name=”author” content=”J.d. (Jon Daniel)” />
<meta name=”copyright” content=”http://ehime.deviantart.com” />
<meta name=”Keywords” content=””/>
<meta name=”Description” content=”Speed (de)MCrypt files” />
<style type=”text/css”>
/* <![CDATA[ */
body{color:#114;background-color:#333;font-family:Verdana;width:60%;}
h2{color:#eee;padding:6px;font-size:16px;}div{width:98%;padding:6px;margin:6px;}
form{height:360px;}
.button {margin-top:-25px;}
div.output{color:#114;background-color:#ccc;border:1pxdashed#fff;font-size:10px;}
div.input{height:50%;background-color:#000;border:1pxdashed#0f0;}
textarea.code{width:100%;height:300px;color:#0f0;background-color:#000;border:none;}
input{background-color:#eee;color:#262;border:2pxsolid#ccc;font-weight:bold;}a.credits{color:#9f9;}
div.credtis{color:#bbb;margin-top:50px;font-size:10px;}
/* ]]> */
</style>
<script type=”text/javascript”>
function clearCode() {
var srcCode = document.getElementById(‘phpCode’);
if (srcCode) { srcCode.value = “”; } }
</script>
</head>
<body>
<div class=”output” style=”background-color:black”>
<?php
switch ($_POST[‘crypt’]) {
case ‘encrypt’:
$output = $_POST[‘phpCode’];
fixoutput($output);
# Trying to remove illegals, hasn’t worked yet
$pattern = array ( “#°#”, “#Â#”, “#’#”);
$replace = array ( ‘and#176;’, ”, ”’);
$output = preg_replace($pattern, $replace, $output);
$sub_directory = “/prl/”;
$output = str_replace(“r”,””,$output);
$output = str_replace(“n”,””,$output);
$output = str_replace(“/lighting/”,$sub_directory,$output);
$output = encrypt($output);
$output = chunk_split($output, 85, “‘.rn'”);
$pattern = array(
‘//’, # Backslashes
‘#.s*’Z#’ # Trail Ending :: Added lastline switch Z
);
$replace = array(
”, # Blank
‘;’ # End of Line
);
$output = preg_replace($pattern, $replace, $output);
echo “<br /><b style=’color:red;’>Cipher:</b><br />rn”;
echo “<textarea style=’width:99.3%;background-color:#000;color:#0f0;’>’$output</textarea>rn”;
echo “<br />rn”;
$input = decrypt($output);
$input = stripslashes($input);
echo “<br /><b style=’color:red;’>Rendered:</b>rn”;
echo “<div style=’color:#0f0;’> $input </div><br />”;
break;
case ‘decrypt’:
$output = decrypt($_POST[‘phpCode’]);
/* replaces vibration = vibr /ation, no good yo. */
$pattern = array(“#<br>#”,”#<br / />#”, “#<<#”, “#>>#”);
$replace = array(“<br />”,”<br />”, “<“, “>”);
$output = preg_replace($pattern, $replace, $output);
$input = htmlspecialchars(stripslashes($output));
echo “<br /><b style=’color:red;’>Source Code:</b><br />rn”;
echo “<textarea style=’width:99.3%;background-color:#000;color:#0f0;’> $input </textarea>rn”;
echo “<br />rn”;
$output = stripslashes($output);
echo “<br /><b style=’color:red;’>Rendered:</b>rr”;
echo “<div style=’color:#0f0; margin-right:-25px’>$output</div><br />r”;
break;
}
?>
</div>
<div class=”input”><form action=”<?=$_SERVER[‘PHP_SELF’] ?>” method=”post”>
<div style=’margin:5px 0;’>
<input class=”button” type=”button” value=”Clear Code” onclick=”javascript:clearCode();” /><?=$sp;?>
<input class=”button” type=”submit” value=”Execute Code” /><?=$sp;?>
<b style=”color:#fff; border:1px dashed #0f0; padding:5px;”><input type=”radio” name=”crypt” value=”encrypt” checked=”checked” /> +
<input type=”radio” name=”crypt” value=”decrypt” /> – </b><?=$sp;?><b style=”color:#fff;margin-left:7px;”>
<?=”Salt: r”?>
<?=”<textarea style=’position:relative;top:4px;width:22%;height:18px;background-color:#000;color:#0f0;’> $salt</textarea>r”?>
</b>
</div>
<textarea id=”phpCode” name=”phpCode” class=”code” rows=”0″ cols=”0″><?php
if (isset($_POST[‘phpCode’])) echo htmlentities(stripslashes($_POST[‘phpCode’])) ?></textarea><br /><br />
</form>
</div>
<div class=”credtis”>
<strong>MCrypt v<?=VERSION ?></strong>
<a href=”http://omnisistem.com/” target=”_blank” class=”credits”>(About)</a><br />
—<br />
Disclaimer:<br />
Use at your own risk. No warranty implied.<br />
<br />
© 2oo9 – jd!<a href=”http://omnisistem.com” target=”_blank” class=”credits”>OmniSistem</a><br />
</div>
</body>
</html>