Commit bfd01572 authored by f4eyq's avatar f4eyq

update 28/1/2019

parent 5e13530d
......@@ -4,6 +4,14 @@ Current version:2.0.1
Update:12/2018
Date:01/2008
------------------------
Update 27/01/2019
------------------------
- minor change on app path.
------------------------
Update 13/01/2019
------------------------
- update lib crxEncrypt for lib SODIUM ( new with PHP 7.2 ) witch replace MCRYPT.
------------------------
Update 31/12/2018
------------------------
- minor change on ham mode lib.
......
......@@ -759,7 +759,7 @@ class crxFramework extends crxCore{
function debugFile($message){
if(!self::$_debugTxtFilePath)$debug_messages_file = _APPLI_MAIN_PATH_ . _SD_ . "logs" . _SD_ . "messages.debug";
if(!self::$_debugTxtFilePath)$debug_messages_file = _APPLI_MAIN_PATH_ROOT_ . _SD_ . "logs" . _SD_ . "messages.debug";
else $debug_messages_file = self::$_debugTxtFilePath;
$content_log=crxFile::getFileContent($debug_messages_file);
......
......@@ -600,7 +600,6 @@ class crxFrameworkWebCommon {
return;
}
//form_login form_pwd savePassword
......@@ -617,9 +616,6 @@ class crxFrameworkWebCommon {
}
if(!crxFramework::getLoginUserStatus()){
//Try to login-in with user cookie !
......@@ -635,6 +631,7 @@ class crxFrameworkWebCommon {
$_COOKIE['crx_pwd'])
){
//@APPEND CODE
$url_encodage_mode = crxFramework::getFrameworkConfigurationValue('enforceUriSecurityMode');
if($url_encodage_mode=='b64id'){
......@@ -727,14 +724,8 @@ class crxFrameworkWebCommon {
}
}//if(!crxFramework::getLoginUserStatus()){
//TEST /
//php7 addon :
if(isset($uri['data']['action']) && crxFramework::getLoginUserStatus() && $uri['data']['action'] == 'crxFrameworkAuthUser'){
......@@ -788,8 +779,7 @@ class crxFrameworkWebCommon {
$_COOKIE['crx_log'],
$_COOKIE['crx_pwd'])
){
){
//@APPEND CODE
$url_encodage_mode = crxFramework::getFrameworkConfigurationValue('enforceUriSecurityMode');
if($url_encodage_mode=='b64id'){$uri = '?id=';}
......@@ -797,8 +787,6 @@ class crxFrameworkWebCommon {
$this->__initUserWebInterfaceLanguage();
return array(
'disable_module_loading_process' => TRUE,
'redirect_process' => $uri.$this->encodeUrl(
......
......@@ -20,10 +20,10 @@
/**
* @author Bastien Barbe - CRX-FRAMEWORK (cms part)
* @date 01/01/2005
* @revision 10/2018
* @revision 27012019
* @package core/crxUsers,frameworkCrxUser.
* @copyright see header
* @version 1.8 ( 1.8 add sms/mobile support).
* @version 1.8.1 ( 1.8 add sms/mobile support).
*/
abstract class frameworkCrxUser
......@@ -641,30 +641,34 @@ $exec='curl -X POST '.$uri.' \
)
);
$this->_dataAccess -> execSql();
$this->_dataAccess -> execSql();
$m_ = $l = $this->_dataAccess->returnLine();
$l = $this->_dataAccess->returnLine();
$m_=$l;
$this->__loadCrxSysLog();
$ip=$this->getIP();
$this->__loadCrxSysLog();
$ip = $this->getIP();
$m="succefully open web session.";
if(!$l){
$m="failed to open web session.";
}else{
$m="succefully open web session.";
}
if($l['account_enable']<>1){
}
if(isset($m_['id_user']) && $l['account_enable']<>1){
$m="account not enable.";
$l=FALSE;
}
$uid=$m_['id_user'];
$call=$m_['callsign_main'];
$_logEntry="[".date('d/m/Y H:i:s')."][SECURITY:LOGIN][User : ".$login." ".$m."][".$uid."][".$ip."][".$call."]";
}
$uid=-1;
if(isset($m_['login_user'])) $call = $m_['login_user'];
if(isset($m_['callsign_main'])) $call .= '/'.$m_['callsign_main'];
if(isset($m_['id_user'])){
$uid=$m_['id_user'];
$call='['.$call.']';
}
$_logEntry="[".date('d/m/Y H:i:s')."][SECURITY:LOGIN][User : ".$login."][".$m."][".$uid."][".$ip."]".$call;
$this->goCrxLog -> reportMessage($_logEntry,'securityInfo');
return $l;
}
function getGroupRootUserId(){
......
......@@ -2,10 +2,10 @@
/**
* @author Bastien Barbe - CRX-FRAMEWORK (cms part)
* @date 01/01/2005
* @revision 02/02/2008
* @revision 13/01/2019
* @module crypto
* @copyright see header
* @version 1.1.20080203
* @version 1.2.1
*/
class crxEncrypt{
......@@ -13,13 +13,72 @@
if(function_exists('mcrypt_encrypt')){
$this->_mcryptLibraireIsAvalaible=true;
}
//$this->_mcryptLibraireIsAvalaible=false;
//$this->_mcryptLibraireIsAvalaible=false
}
function encryptSodium($message,$key,$nonce){
if(!SODIUM_LIBRARY_VERSION)die('missing SODIUM_LIBRARY');
$ad = 'pubdata';
$ciphertext = sodium_crypto_aead_xchacha20poly1305_ietf_encrypt(
$message,
$ad,
$nonce,
$key
);
return $ciphertext;
}
function decryptSodium($ciphertext,$key,$nonce){
if(!SODIUM_LIBRARY_VERSION)die('missing SODIUM_LIBRARY');
$ad = 'pubdata';
$decrypted = sodium_crypto_aead_xchacha20poly1305_ietf_decrypt(
$ciphertext,
$ad,
$nonce,
$key
);
/*@todo if ($decrypted === false) {throw new Exception("Bad ciphertext");}*/
return $decrypted;
}
//dep
function enableMCrypt($c=1){
$this->_mcryptLibraireIsAvalaible=$c;
}
//dep
function encrypt_RIJNDAEL_128($decrypted, $password='a2b', $salt='@kQm*fA3pXe1Kbm%1') {
// Build a 256-bit $key which is a SHA256 hash of $salt and $password.
$key = hash('SHA256', $salt . $password, true);
// Build $iv and $iv_base64. We use a block size of 128 bits (AES compliant) and CBC mode. (Note: ECB mode is inadequate as IV is not used.)
srand(); $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
if (strlen($iv_base64 = rtrim(base64_encode($iv), '=')) != 22) return false;
// Encrypt $decrypted and an MD5 of $decrypted using $key. MD5 is fine to use here because it's just to verify successful decryption.
$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $decrypted . md5($decrypted), MCRYPT_MODE_CBC, $iv));
// We're done!
return $iv_base64 . $encrypted;
}
//dep
function decrypt_RIJNDAEL_128($encrypted, $password='a2b', $salt='@kQm*fA3pXe1Kbm%1') {
// Build a 256-bit $key which is a SHA256 hash of $salt and $password.
$key = hash('SHA256', $salt . $password, true);
// Retrieve $iv which is the first 22 characters plus ==, base64_decoded.
$iv = base64_decode(substr($encrypted, 0, 22) . '==');
// Remove $iv from $encrypted.
$encrypted = substr($encrypted, 22);
// Decrypt the data. rtrim won't corrupt the data because the last 32 characters are the md5 hash; thus any \0 character has to be padding.
$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, base64_decode($encrypted), MCRYPT_MODE_CBC, $iv), "\0\4");
// Retrieve $hash which is the last 32 characters of $decrypted.
$hash = substr($decrypted, -32);
// Remove the last 32 characters from $decrypted.
$decrypted = substr($decrypted, 0, -32);
// Integrity check. If this fails, either the data is corrupted, or the password/salt was incorrect.
if (md5($decrypted) != $hash) return false;
// Yay!
return $decrypted;
}
//dep
function encrypt($string_encrypt){
if($this->_mcryptLibraireIsAvalaible){
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
......@@ -37,7 +96,7 @@
}
return $encrypt;
}
//dep
function decrypt($string_decrypt){
if($this->_mcryptLibraireIsAvalaible){
......
......@@ -864,6 +864,14 @@
<class_file>abstractDxClusterSpot.php</class_file>
<is_load>1</is_load>
</item>
<item>
<version>1.0</version>
<class_name>spotNg</class_name>
<class_group>radioamator</class_group>
<class_desc>global class for 11m and HAM dxspot (for mobile version).</class_desc>
<class_file>spotNg.php</class_file>
<is_load>1</is_load>
</item>
<item>
<version>1.0</version>
<class_name>dxClusterSpot</class_name>
......
......@@ -17,10 +17,10 @@
/**
* @author Bastien Barbe - CRX-FRAMEWORK
* @date 01/01/2005
* @revision 07/06/2014
* @revision 20/01/2019
* @lib picture
* @copyright see header
* @version 1.3.20140706
* @version 1.4
*/
define('DEBUG_crxGdPicture',0);
class crxGdPicture{
......@@ -60,9 +60,6 @@ class crxGdPicture{
}
/**
* Saved picture from GD ressource : $this->src_im
*/
......@@ -114,8 +111,7 @@ class crxGdPicture{
imagepng($this->dst_im,$this->finalPath);// Save the new picture
}
}
/**
* Resize picture from GD ressource ( $this->src_img )
*
......@@ -142,7 +138,6 @@ class crxGdPicture{
}
/*
......@@ -302,8 +297,6 @@ class crxGdPicture{
}
}
function getCurrentPictureInfo(){
......@@ -323,7 +316,6 @@ class crxGdPicture{
}
function setType(){}
function resize(){}
......@@ -352,5 +344,181 @@ class crxGdPicture{
}
function generateColor($img='src_im'){
$this->color['black'] = imagecolorallocate($this->$img, 0x00, 0x00, 0x00);
$this->color['yellow'] = imagecolorallocate($this->$img, 255, 255, 0);
$this->color['grey'] = imagecolorallocate($this->$img, 128,128, 128);
$this->color['red'] = imagecolorallocate ($this->$img, 255,0,0);
$this->color['green'] = imagecolorallocate($this->$img, 0, 67, 0);
$this->color['white'] = imagecolorallocate($this->$img, 255, 255, 255);
//$this->color['blue'] = imagecolorallocate($this->$img, 175, 188, 199);
$this->color['blue'] = imagecolorallocate($this->$img, 0x00, 0x00, 0xFF);
}
/**
* Imagettftextgradient v1.0.3
* @category Andrewgjohnson
* @package Imagettftextgradient
* @author Andrew G. Johnson <andrew@andrewgjohnson.com>
* @copyright 2017-2018 Andrew G. Johnson <andrew@andrewgjohnson.com>
* @license https://opensource.org/licenses/mit/ The MIT License
* @link https://github.com/andrewgjohnson/imagettftextgradient
*/
function imagettftextgradient(
// &$image, not neccesary for crx.
$size,
$angle,
$x,
$y,
$color,
$fontfile,
$text,
$gradient_color = null
) {
$image = $this->src_im;
// $gradient_color needs to be an integer returned by imagecolorallocate();
// if it is not we treat this function call identically to imagettftext
if (!is_null($gradient_color) && is_int($gradient_color)) {
// $return_array will be returned once all calculations are complete
$return_array = [
imagesx($image), // lower left, x coordinate
-1, // lower left, y coordinate
-1, // lower right, x coordinate
-1, // lower right, y coordinate
-1, // upper right, x coordinate
imagesy($image), // upper right, y coordinate
imagesx($image), // upper left, x coordinate
imagesy($image) // upper left, y coordinate
];
// $temporary_image is a GD image that is the same size as our
// original GD image
$temporary_image = imagecreatetruecolor(
imagesx($image),
imagesy($image)
);
// fill $temporary_image with a black background
imagefill(
$temporary_image,
0,
0,
imagecolorallocate($temporary_image, 0x00, 0x00, 0x00)
);
// add white text to $temporary_image with the function call's
// parameters
$temporary_text = imagettftext(
$temporary_image,
$size,
$angle,
$x,
$y,
imagecolorallocate($temporary_image, 0xFF, 0xFF, 0xFF),
$fontfile,
$text
);
if ($temporary_text !== false) {
// calculate the text's top & bottom most pixels
$text_top = min($temporary_text[5], $temporary_text[7]);
$text_bottom = max($temporary_text[1], $temporary_text[3]);
$text_height = $text_bottom - $text_top;
// loop through each pixel in $temporary_image
for ($_x = 0; $_x < imagesx($temporary_image); $_x++) {
for ($_y = 0; $_y < imagesy($temporary_image); $_y++) {
// $visibility is the grayscale of the current pixel
$visibility = (imagecolorat(
$temporary_image,
$_x,
$_y
) & 0xFF) / 255;
// if the current pixel would not be invisible then add it to
// $image
if ($visibility > 0) {
// we know we are on an affected pixel so ensure
// $return_array is updated accordingly
$return_array[0] = min($return_array[0], $_x);
$return_array[1] = max($return_array[1], $_y);
$return_array[2] = max($return_array[2], $_x);
$return_array[3] = max($return_array[3], $_y);
$return_array[4] = max($return_array[4], $_x);
$return_array[5] = min($return_array[5], $_y);
$return_array[6] = min($return_array[6], $_x);
$return_array[7] = min($return_array[7], $_y);
// determine the current pixel's RGB color code & alpha
// value by first calculating its position within the
// text
$gradient_position = ($_y - $text_top) / $text_height;
$color_red = ($color >> 16) & 0xFF;
$color_red *= 1 - $gradient_position;
$gradient_color_red = ($gradient_color >> 16) & 0xFF;
$gradient_color_red *= $gradient_position;
$red = round($color_red + $gradient_color_red);
$color_green = ($color >> 8) & 0xFF;
$color_green *= 1 - $gradient_position;
$gradient_color_green = ($gradient_color >> 8) & 0xFF;
$gradient_color_green *= $gradient_position;
$green = round($color_green + $gradient_color_green);
$color_blue = $color & 0xFF;
$color_blue *= 1 - $gradient_position;
$gradient_color_blue = $gradient_color & 0xFF;
$gradient_color_blue *= $gradient_position;
$blue = round($color_blue + $gradient_color_blue);
$color_opacity = imagecolorsforindex(
$image,
$color
)['alpha'];
$color_opacity *= 1 - $gradient_position;
$gradient_color_opacity = imagecolorsforindex(
$image,
$gradient_color
)['alpha'];
$gradient_color_opacity *= $gradient_position;
$opacity = $color_opacity + $gradient_color_opacity;
$opacity = (127 - $opacity) / 127;
// set the current pixel in $image
imagesetpixel(
$image,
$_x,
$_y,
imagecolorallocatealpha(
$image,
$red,
$green,
$blue,
(1 - $visibility) * 127 * $opacity
)
);
}
}
}
}
// destroy our $temporary_image
imagedestroy($temporary_image);
return $return_array;
} else {
return imagettftext(
$image,
$size,
$angle,
$x,
$y,
$color,
$fontfile,
$text
);
}
}
}
?>
......@@ -51,8 +51,6 @@ class crxFrequencyMap{
$this->_xml_htmlForm = simplexml_load_file($this->path_input_def);
foreach ($this->_xml_htmlForm->xpath('//bands') as $opt) {
foreach($opt as $opt_key=>$item_opt){
......
......@@ -52,12 +52,13 @@ VALUES (
class hamCountry{
var $_debug_name_and_dxcc_id = '';
var $_debug_name_and_dxcc_id = '';
var $_table_dxcc_country = 'country';
var $debug = 0;
var $_debug = '';
var $debug = 0;
var $_debug = '';
var $_found_club_log_exeption = false;
......@@ -274,7 +275,7 @@ class hamCountry{
function handle__clublog_prefix__calcDxccSpiderID(){
if($this->debug){echo _BR_."Use <b>clublog_prefix</b>"._BR_._BR_;}
if($this->debug){echo 'Use <b>clublog_prefix</b>'._BR_._BR_;}
$sqlg = 'SELECT * FROM `crx_country_prefix_clublog` WHERE `call` = ';
$sqlmap = 'SELECT country_id_dxspider, country_prefix_adif, country_is_deleted, country_name
......@@ -289,9 +290,6 @@ class hamCountry{
4=>$this->first_letter
);
foreach($try as $k=>$call_part){
$q="$sqlg'".$call_part."'";
$this->c_db -> execSql($q);
......@@ -304,8 +302,6 @@ class hamCountry{
if($this->debug){
echo "=> Try callsign part : <b>".$try[$k]."</b>."._BR_._BR_;
}
if( $pfx > 0 ){
......@@ -314,17 +310,12 @@ class hamCountry{
$this->_tryOtherMethod=1;
$this->_found_club_log_entities=$prefix;
echo "=> Found : <b>".$try[$k]."</b>."._BR_._BR_;
}
//var_dump($prefix);
if($k==3 or $k==4){
$this->_tryOtherMethod=1;
}
foreach($prefix as $k1=>$v1){
$q=$sqlmap.$v1['adif'];
$this->c_db -> execSql($q);
......@@ -356,7 +347,7 @@ class hamCountry{
}
}
}
if($this->date_qso && $current_pfx['start']){
$prefix_start = NULL;
......@@ -488,7 +479,6 @@ class hamCountry{
}
if($pfx>=2){
/*
-----------------------------------------------------------------
......@@ -497,22 +487,43 @@ class hamCountry{
-----------------------------------------------------------------
*/
$cnt=count($prefix) - 1; //2
$cnt=0;//Last is on the top.
//var_dump($cnt);
//var_dump($prefix);
//var_dump($country_found);
$cnt=0;//Last is on the top.
$last_adif_id=$prefix[$cnt]['adif'];
if(isset($country_found[$last_adif_id]['country_id_dxspider'])){
$cont=-1;
//$this->date_qso
$debug='';
foreach($prefix as $kpf=>$pff){
if($pff['end']){
$pff['end'] = crxDate::parseDateAndReturnTimeStamp($pff['end']);
if($this->date_qso < $pff['end']){$cont=$kpf;}
$debug.=$pff['entity']." / ";
}
}
if($cont == -1){
if($this->debug){
echo "(clublog_prefix) \ Found callsign with adif key :<b>".$last_adif_id."</b>, <b>".$pfx."</b>
prefix present (".$debug.") but QSO date > these prefix .<br />";
}
return;
}
$last_adif_id=$prefix[$cont]['adif'];
if($this->debug){
echo "(clublog_prefix) \ Found callsign with adif key :<b>".$last_adif_id."</b>, 2 prefix present but we dont have QSO date we choose the most recent .<br />";
echo "(clublog_prefix) \ Found callsign with adif key :<b>".$last_adif_id."</b>, <b>".$pfx."</b>
prefix present but we dont have QSO date we choose the most recent .<br />";
}
$this->_dxcc_id=$country_found[$last_adif_id]['country_id_dxspider'];
return $country_found[$last_adif_id]['country_id_dxspider'];
}
}
}
}
}
......@@ -549,10 +560,8 @@ class hamCountry{
$this->c_db -> execSql($q);
$r=$this->c_db -> returnLine();
if(isset($r[0])){
$this->_dxcc_id=$r['country_id_dxspider'];
......@@ -595,7 +604,6 @@ class hamCountry{
$this->_result[]='(clublog_except)\(semi) QSO date > '.date('d/m/Y',$prefix_start).' (prefix date start, prefix call '.$current_pfx['call'].')';
$this->_dxcc_id=$current_pfx['country_id_dxspider'];
if($this->debug)echo _BR_."(clublog_except)\(semi)Correct callsign <b>".$this->_hamCallsign."</b> match with date start of the prefix call exception : <b>".date('d/m/Y',$prefix_start)."</b>";
return $this->_dxcc_id;
......@@ -713,8 +721,6 @@ class hamCountry{
if($this->debug){echo _BR_."Use <b>dxspider_except</b><br />";}
$callsign=$this->_hamCallsign;
$q="SELECT * FROM `crx_country_prefix_list_mapper` WHERE `pl_id` LIKE '=$callsign'";
$this->c_db -> execSql($q);
$r=$this->c_db -> returnLine();
......@@ -740,9 +746,6 @@ class hamCountry{
echo _BR_."Callsign not found in <b>dxspider exception</b> !<br />";
}
}
function handle__dxspider_prefix__calcDxccSpiderID(){
......@@ -797,9 +800,6 @@ class hamCountry{
$this->_dxcc_id=$key_prefix_loc=$r['p_dxcc'];
$this->_tryOtherMethod=0;
if($this->debug){
......@@ -842,10 +842,13 @@ class hamCountry{
}
var $_order_algo = array(
'clublog_except',
'clublog_prefix',
'dxspider_except',
'dxspider_prefix'
);
function calcDxccSpiderID(){
......@@ -859,13 +862,12 @@ class hamCountry{
$this->five_first_letter = substr($this->_hamCallsign,0,5);
foreach($this->_order_algo as $k=>$alg){
$h='handle__'.$alg.'__calcDxccSpiderID';
//echo $h._BR_;
$h._BR_;
$rs = $this->$h();
if($rs && !$this->_tryOtherMethod){
if($this->debug){
echo "<br/><br/><u>Found result:</u><br />";
......@@ -873,9 +875,6 @@ class hamCountry{
var_dump($this->getCountryInfoFromDxSpiderId($this->_dxcc_id));
}
return $rs;
}
}
......
......@@ -8,6 +8,28 @@
*/
class spotMode{
//PROP_MODE adif key:
var $_modes_prop