1
Off Topic / Re: Ctrl + V game.
« on: June 26, 2009, 11:27:53 PM »Code: [Select]
<?
session_start();
function encrypt($text, $seed) {
$encText = "";
$pwLength = strlen($seed);
$i=6;
for ($x=0; $x < strlen($text); $x++) {
$i = ($i%$pwLength)+1;
$a = ord(substr($text, $x, 1));
$b = ord(substr($seed, $i-1, 1));
$encText .= ($a ^ $b);
$encText .= ",";
}
return $encText;
}
/* function decrypt($text, $seed){
if(!$text == ""){
if (strlen($text) == 1)
return "999999";
$pwLength = strlen($seed);
$strText = "";
$hold;
$i = 6;
$crypt = explode("," ,$text);
for ($x = 0; $x < sizeof($crypt) - 1; $x++) {
if (strlen($crypt[$x])>2) {
$test=0;
$test = (int) $crypt[$x];
if ($test == 0) $crypt[$x] = substr($crypt[$x], 1,1);
}
$i = ($i % $pwLength) + 1;
$a = (int)($crypt[$x]);
$b = ord(substr($seed, $i-1, 1));
$hold = chr($a ^ $b);
$strText .= $hold;
}
return trim($strText);
}else{
return "";
}
} */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>MicroMsg - Send Item</title>
</head>
<body style="font-family:Verdana, Arial, Helvetica, sans-serif">
<?
$numFiles = 0;
if ($handle = opendir("Users/" . $_POST['rec'] . "/Messages")) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != ".DS_Store" && $file != ".htaccess") {
$numFiles++;
}
}
closedir($handle);
}
if ($_POST['message'] != "") {
$message = str_replace("\n", "<br />", $_POST['message']);
if ($_POST['enc'] == "Encrypted") {
$message = encrypt($message, $_POST['rec']);
}
$xmlData = "<data>\n";
$xmlData .= "\t<flag>" . $_POST['flag'] . "</flag>\n";
$xmlData .= "\t<enc>" . $_POST['enc'] . "</enc>\n";
$xmlData .= "\t<sender>" . $_SESSION['username'] . "</sender>\n";
$xmlData .= "\t<subject>" . $_POST['subject'] . "</subject>\n";
$xmlData .= "\t<message>" . $message . "</message>\n";
$xmlData .= "</data>";
fwrite(fopen("Users/" . $_POST['rec'] . "/Messages/" . ($numFiles) . ".msg" , 'w'), $xmlData);
echo "Message Sent";
}else{
echo "Could not send message, it is empty";
}
?>
</body>
</html>
PHP Anyone?