Skip to content

Commit

Permalink
2.1.27
Browse files Browse the repository at this point in the history
Code review with Codacy
  • Loading branch information
nilsteampassnet committed Jul 30, 2017
1 parent 661f660 commit cdf1327
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 62 deletions.
10 changes: 8 additions & 2 deletions admin.settings.load.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,15 @@ function LaunchAdminActions(action, option)
} else if (action === "admin_action_backup_decrypt") {
option = $("#bck_script_decrypt_file").val();
} else if (action === "admin_action_change_salt_key") {
option = aes_encrypt(sanitizeString($("#new_salt_key").val()));
option = prepareExchangedData(
sanitizeString($("#new_salt_key").val()),
"encode",
"<?php echo $_SESSION['key']; ?>"
);
} else if (action === "admin_email_send_backlog") {
$("#email_testing_results").show().html("<?php echo addslashes($LANG['please_wait']); ?>").attr("class","ui-corner-all ui-state-focus");
$("#email_testing_results")
.show().
html("<?php echo addslashes($LANG['please_wait']); ?>").attr("class","ui-corner-all ui-state-focus");
} else if (action === "admin_action_attachments_cryption") {
option = $("input[name=attachments_cryption]:checked").val();
if (option === "" || option === undefined) {
Expand Down
5 changes: 0 additions & 5 deletions find.load.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@

<script type="text/javascript">
//<![CDATA[
function aes_decrypt(text)
{
return Aes.Ctr.decrypt(text, "<?php echo $_SESSION['key']; ?>", 256);
}

/*
* Copying an item from find page
*/
Expand Down
18 changes: 9 additions & 9 deletions includes/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function IncreaseSessionTime(messageEnd, messageWait, duration){
setTimeout(function(){$("#main_info_box").effect( "fade", "slow" );}, 1000);
$("#temps_restant").val(data[0].new_value);
$("#date_end_session").val(data[0].new_value);
$('#countdown').css("color","white");
$("#countdown").css("color","white");
$("#div_increase_session_time").dialog("close");
} else {
document.location = "index.php?session=expired";
Expand All @@ -67,7 +67,7 @@ function IncreaseSessionTime(messageEnd, messageWait, duration){
**/
function countdown()
{
var DayTill
var DayTill;
var theDay = $("#temps_restant").val();
var today = new Date(); //Create an Date Object that contains today's date.
var second = Math.floor(theDay - (today.getTime()/1000));
Expand Down Expand Up @@ -179,7 +179,7 @@ function CreateRandomString(size,type){
**/
function unsanitizeString(string){
if(string !== "" && string !== null){
string = string.replace(/\\/g,'').replace(/&#92;/g,'\\');
string = string.replace(/\\/g,"").replace(/&#92;/g,"\\");
}
return string;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ function SendMail(category, contentEmail, keySent, message){
key : keySent
},
function(data){
if (data[0].error !== undefined && data[0].error !== "") {
if (typeof data[0].error !== 'undefined' && data[0].error !== "") {
message = data[0].message;
}
$("#div_dialog_message_text").html(message);
Expand Down Expand Up @@ -245,7 +245,7 @@ function extractLast( term ) {
}


function store_error(messageError, dialogDiv, textDiv){
function storeError(messageError, dialogDiv, textDiv){
//Store error in DB
$.post(
"sources/main.queries.php",
Expand All @@ -259,13 +259,13 @@ function store_error(messageError, dialogDiv, textDiv){
$("#"+dialogDiv).dialog("open");
}

function aes_encrypt(text, key)
function aesEncrypt(text, key)
{
return Aes.Ctr.encrypt(text, key, 256);
}


function aes_decrypt(text, key)
function aesDecrypt(text, key)
{
return Aes.Ctr.decrypt(text, key, 256);
}
Expand Down Expand Up @@ -297,7 +297,7 @@ function prepareExchangedData(data, type, key)
}
} else {
try {
return $.parseJSON(aes_decrypt(data, key));
return $.parseJSON(aesDecrypt(data, key));
}
catch (e) {
return "Error: " + jsonErrorHdl(e);
Expand All @@ -307,7 +307,7 @@ function prepareExchangedData(data, type, key)
if ($("#encryptClientServer").val() === "0") {
return data;
} else {
return aes_encrypt(data, key);
return aesEncrypt(data, key);
}
} else {
return false;
Expand Down
4 changes: 2 additions & 2 deletions items.import.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ function launchCSVItemsImport()
"sources/import.queries.php",
{
type : "import_items",
folder : $("#import_items_to").val(),
data : aes_encrypt(items),
folder : $("#import_items_to").val(),
data : prepareExchangedData(items , "encode", "<?php echo $_SESSION['key']; ?>"),
import_csv_anyone_can_modify : $("#import_csv_anyone_can_modify").prop("checked"),
import_csv_anyone_can_modify_in_role : $("#import_csv_anyone_can_modify_in_role").prop("checked")
},
Expand Down
11 changes: 0 additions & 11 deletions items.load.php
Original file line number Diff line number Diff line change
Expand Up @@ -4011,17 +4011,6 @@ function(data) {
}


function aes_encrypt(text)
{
return Aes.Ctr.encrypt(text, "<?php echo $_SESSION['key']; ?>", 256);
}


function aes_decrypt(text)
{
return Aes.Ctr.decrypt(text, "<?php echo $_SESSION['key']; ?>", 256);
}

/*
* Launch the redirection to OTV page
*/
Expand Down
6 changes: 0 additions & 6 deletions load.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,6 @@ function MenuAction(val, user_id)
}
}
function aes_encrypt(text)
{
return Aes.Ctr.encrypt(text, "'.$_SESSION['key'].'", 256);
}
function launchIdentify(isDuo, redirect, psk)
{
$("#connection_error").hide();
Expand Down
4 changes: 0 additions & 4 deletions sources/import.queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ function sanitiseString($str, $crLFReplacement)
$aes = new SplClassLoader('Encryption\Crypt', '../includes/libraries');
$aes->register();

// Load AntiXSS
require_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/AntiXSS/AntiXss.php';
$antiXss = new protect\AntiXSS\AntiXSS();

//User's language loading
$SETTINGS_EXT['langage'] = @$_SESSION['user_language'];
require_once $SETTINGS['cpassman_dir'].'/includes/language/'.$_SESSION['user_language'].'.php';
Expand Down
4 changes: 0 additions & 4 deletions sources/items.queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@
require_once $SETTINGS['cpassman_dir'].'/includes/libraries/phpcrypt/phpCrypt.php';
use PHP_Crypt\PHP_Crypt as PHP_Crypt;

// Load AntiXSS
require_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/AntiXSS/AntiXss.php';
$antiXss = new protect\AntiXSS\AntiXSS();

// Prepare POST variables
$post_page = filter_input(INPUT_POST, 'page', FILTER_SANITIZE_STRING);
$post_type = filter_input(INPUT_POST, 'type', FILTER_SANITIZE_STRING);
Expand Down
31 changes: 16 additions & 15 deletions sources/main.functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,21 @@ function decryptOld($text, $personalSalt = "")
)
)
);
} else {
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
)
)
);
}

// No personal SK
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
)
)
);
}

/**
Expand All @@ -178,9 +179,9 @@ function encrypt($decrypted, $personalSalt = "")
}

if (!empty($personalSalt)) {
$staticSalt = $personalSalt;
$staticSalt = $personalSalt;
} else {
$staticSalt = SALT;
$staticSalt = SALT;
}

//set our salt to a variable
Expand Down
4 changes: 0 additions & 4 deletions users.load.php
Original file line number Diff line number Diff line change
Expand Up @@ -1319,10 +1319,6 @@ function(data) {
);
}

function aes_decrypt(text)
{
return Aes.Ctr.decrypt(text, "<?php echo $_SESSION['key']; ?>", 256);
}

function htmlspecialchars_decode (string, quote_style)
{
Expand Down

0 comments on commit cdf1327

Please sign in to comment.