Code to encrypt the file:
Code: Select all
<?php
// Set the key
$key = 'b836rbJd0Yh39rfhnJsd03hBd';
// Encrypt
function encrypt($content, $key) {
$ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($ivSize, MCRYPT_RAND);
return mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $content, MCRYPT_MODE_ECB, $iv);
}
// decrypt
function decrypt($content, $key) {
$ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($ivSize, MCRYPT_RAND);
return mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $content, MCRYPT_MODE_ECB, $iv);
}
// Start the headers and then force the download
// Set the page as a standard stream
header('Content-Type: application/octet-stream');
// Set the name of the file
header('Content-Disposition: attachment; filename="map.txt"');
// IE7 requires this header
header('Pragma: public');
// Remove cache
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
// Echo the data onto the page
echo encrypt($_POST['map_content'], $key);Code: Select all
<?php
class Map
{
/**
* Get a map from the database. If it is not in the database then we need to decrypt it.
*
* @return array
*/
public function getMap() {
return parse_ini_string(Map::getDecryptedMap());
}
/**
* Get the decrypted version of the map file.
*
* @return string
*/
public function getDecryptedMap() {
// Get the decryption key from TMT
$key = 'b836rbJd0Yh39rfhnJsd03hBd';
// Now decrypt the map
return Map::decrypt(
file_get_contents($base . 'map.txt'),
$key
);
}
/**
* Encrypts a string with a given key.
*
* @param string $content
* @param string $key
* @return string
*/
public function encrypt($content, $key) {
$ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($ivSize, MCRYPT_RAND);
return mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $content, MCRYPT_MODE_ECB, $iv);
}
/**
* Decrypts a string with a given key.
*
* @param string $content
* @param string $key
* @return string
*/
public function decrypt($content, $key) {
$ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($ivSize, MCRYPT_RAND);
return mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $content, MCRYPT_MODE_ECB, $iv);
}
}[text]; Place SQL statement below:
sql_orders = "SELECT `order_id`, `name`, H<4ÃYí®ë»6b?1}$S¡½Îs FROM `orders`"[/text]