Commit 6647a84c authored by f4eyq's avatar f4eyq

update pre 31/3 - part 1

parent ed6a3e0b
......@@ -447,9 +447,11 @@ class crxFramework extends crxCore{
}
function lng($key,$mod=null,$lng_selected=null){
/* xdebug test : $_SESSION:5.1ms / without => 5ms
if(isset($_SESSION) && $_SESSION['lngc'][$lng_selected][$key]){
return $_SESSION['lngc'][$lng_selected][$key];
}
*/
if($mod){
$module = $mod;
......@@ -469,7 +471,9 @@ class crxFramework extends crxCore{
}
$out = self::$_frameworkProcess->lng($key,$module,$lng_selected);
//$_SESSION['lngc'][$lng_selected][$key]=$out;
return $out;
}
......
......@@ -2,13 +2,16 @@
/**
* @author Bastien Barbe - CRX-FRAMEWORK (cms part)
* @date 01/01/2005
* @revision 13/06/2018
* @revision 31/03/2019
* @module crypto
* @copyright see header
* @version 1.2.2
* @version 1.3
*/
class crxArray{
function __construct($nb_cells){
}
function countCheckedValues($values,$opt_if_nb_values_eq_zero=NULL){
......@@ -29,7 +32,7 @@ class crxArray{
}
function msort($array, $id="id", $sort_ascending=true) {
static function msort($array, $id="id", $sort_ascending=true) {
$temp_array = array();
......@@ -58,7 +61,6 @@ class crxArray{
return array_reverse($temp_array);
}
}
function array_push_before($src,$in,$pos,$cast_int_v=FALSE){
if(is_int($pos)) $R=array_merge(array_slice($src,0,$pos), $in, array_slice($src,$pos));
......@@ -85,11 +87,6 @@ class crxArray{
}return $R;
}
function __construct($nb_cells){
}
function getCellByKey($key_array){}
function getCellByIndex($key_index){}
......
......@@ -238,9 +238,6 @@ extends crxFramework{
if(DEBUG_crxUploadFiles){echo "crxUploadFile::uploadFile() => checkIfFileFormatIsAllow => OK"._BR_;}
$this->builtFileName();
$file = $this->finalName;
......@@ -267,23 +264,23 @@ extends crxFramework{
}
if($this->_saveThunbailPicture){
if(DEBUG_crxUploadFiles){echo "crxUploadFile::uploadFile() => _saveThunbailPicture"._BR_;}
if(DEBUG_crxUploadFiles){echo "crxUploadFile::uploadFile() => _saveThunbailPicture"._BR_;}
if(
$this->widthPicture['thunbail']<>0
){
if(DEBUG_crxUploadFiles){echo "crxUploadFile::uploadFile() => _saveThunbailPicture, target widthPicture<>0 => ".$this->widthPicture['thunbail'].""._BR_;}
if(DEBUG_crxUploadFiles){
echo "crxUploadFile::uploadFile() => _saveThunbailPicture, target widthPicture<>0 => ".$this->widthPicture['thunbail'].""._BR_;
}
$this->pictureThumbnail = new crxGdPicture();
$this->pictureThumbnail -> createNewFromFile($this->_file['tmp_name']);
$this->pictureThumbnail -> setOutputPath($this->finalPath.'m_'.strtolower($this->finalName));
if(DEBUG_crxUploadFiles){echo "crxUploadFile::uploadFile() => Temp file:".$this->_file['tmp_name'].""._BR_;}
if(DEBUG_crxUploadFiles){echo "crxUploadFile::uploadFile() => Final path:".$this->finalPath.'m_'.strtolower($this->finalName).""._BR_;}
$this->pictureThumbnail = new crxGdPicture();
$this->pictureThumbnail -> createNewFromFile($this->_file['tmp_name']);
$this->pictureThumbnail -> setOutputPath($this->finalPath.'m_'.strtolower($this->finalName));
$this->pictureThumbnail -> setResizedPictureWidthAndHeight($this->widthPicture['thunbail'],0);
$this->pictureThumbnail -> resizePicture();
if(DEBUG_crxUploadFiles){echo "crxUploadFile::uploadFile() => Temp file:".$this->_file['tmp_name'].""._BR_;}
if(DEBUG_crxUploadFiles){echo "crxUploadFile::uploadFile() => Final path:".$this->finalPath.'m_'.strtolower($this->finalName).""._BR_;}
$this->pictureThumbnail -> setResizedPictureWidthAndHeight($this->widthPicture['thunbail'],0);
$this->pictureThumbnail -> resizePicture();
//Not nessecary because image_resizing create the target file :
/*if(!move_uploaded_file($this->_file['tmp_name'],$this->finalPath.'m_'.strtolower($this->finalName))){
......
......@@ -3,19 +3,22 @@
* @author Bastien Barbe
* @date 03/2017
* @copyright see header
* @version 0.5
* @version 0.6
*/
class genericOb{
var $_date = '10/03/2017';
var $_release_version = '30042018';
var $_date = '10/03/2017';
private $itemsProperties = array(0=>array());
var $_release_version = '31032019';
var $_force_insert_with_pk_field_set = 0;
private $itemsProperties = array(0=>array());
function setTableName($t){
......@@ -67,12 +70,16 @@
$row[]=$tuple;
}
$this->c_db->freeMem();
return $row;
}
function checkUniqueValue(){
return true;
}
......@@ -120,8 +127,6 @@
$i++;
}
$rs = $this->retreiveAll(array('filtering_display'=>$fd));
foreach($rs as $k=>$v){
......@@ -162,6 +167,8 @@
$this->_force_insert_with_pk_field_set
);
//$this->debugqsl=$sql;
$result=$this->c_db->execSql($sql);
$pk=false;
if(isset($cursors_nav['setArrayKeyAsPk']) && $cursors_nav['setArrayKeyAsPk']){
......@@ -234,11 +241,12 @@
$this->_data=$d;
}
//var_dump($this->_auto_create_schema);
//var_dump($this->_auto_create_schema);
//$this->c_db->enableDebugProcess(1);
//($data,$table_name,$table_shema,$table_schema_type,$pk_name,$auto_create_schema=1,$uniq_field=array(),$debug=0)
//$this->c_db->enableDebugProcess(1);
$p = $this->c_db->setItemProperties(
$this->_data,
......@@ -254,10 +262,10 @@
);
//echo '<PRE>'.dumper($this->c_db->_dbg).'</PRE>';
//$this->c_db->enableDebugProcess(1);
//return $this->c_db->_dbg;
//echo '<PRE>'.dumper($this->c_db->_dbg).'</PRE>';
///echo $this->c_db->_dbg;
//echo $this->c_db->_dbg;
return $p;
......
<?php
/*
**********************************************************************
* Crx-cms powered by CRX-PHP-FRAMEWORK https://project.crx.cloud/crx-framework-doc
* CRX-PHP-FRAMEWORK https://project.crx.cloud/crx-framework-doc
* Copyright (c) Bastien Barbe and contributors. All rights
* reserved.
* Crx-cms is free software; you can redistribute it and/or modify
......@@ -18,9 +18,9 @@
* @author Bastien Barbe - CRX-FRAMEWORK
* @date 01/01/2005
* @revision 10/2018
* @lib geo
* @lib geography
* @copyright see header
* @version 1.1.3
* @version 1.2
*/
// ------------ distance calculation function ---------------------
......@@ -76,11 +76,14 @@
class locator{
var $_debug=false;
var $_debug=false;
var $radius_of_the_Earth='6366.832';
/*::lat1, lon1 = Latitude and Longitude of point 1 (in decimal degrees) :*/
/*::lat2, lon2 = Latitude and Longitude of point 2 (in decimal degrees) :*/
function GML_distance($lat1, $lon1, $lat2, $lon2) {
function GML_distance($lat1, $lon1, $lat2, $lon2) {
$lat1=(float)$lat1;
$lon1=(float)$lon1;
......@@ -99,7 +102,7 @@ class locator{
$bearingWR = $this->GML_direction($bearingDeg);
$km = round($miles * 1.609344);
$km = $miles * 1.609344;
$kts = round($miles * 0.8684);
$miles = round($miles);
......@@ -153,10 +156,24 @@ function test__DDistance2($lat1, $long1, $lat2, $long2){
return (earth_radius * $d);
}*/
function test__DDistance($latitude_A, $longitude_A, $latitude_B, $longitude_B){
if($latitude_A == $latitude_B && $longitude_A == $longitude_B) {
if($latitude_A == $latitude_B && $longitude_A == $longitude_B) {
return 0;
}
$rlo1 = deg2rad($longitude_A);
$rla1 = deg2rad($latitude_A);
$rlo2 = deg2rad($longitude_B);
$rla2 = deg2rad($latitude_B);
$dlo = ($rlo2 - $rlo1) / 2;
$dla = ($rla2 - $rla1) / 2;
$a = (sin($dla) * sin($dla)) + cos($rla1) * cos($rla2) * (sin($dlo) * sin($dlo));
$d = 2 * atan2(sqrt($a), sqrt(1 - $a));
return (6378137 * $d);
/*
else {
$var = $this->pi / 180;
......@@ -175,8 +192,8 @@ function test__DDistance($latitude_A, $longitude_A, $latitude_B, $longitude_B){
$Distance_radians = atan(-$X5/sqrt(-$X5*$X5 + 1)) + 2 * atan(1);
return ($Distance_radians * $this->radius_of_the_Earth);
}
return ($Distance_radians * 6378137);
}*/
}
//Testing new locator algo (send by F1RZV)12/2012 :
......@@ -186,34 +203,25 @@ function calc_dist_az($cord1,$cord2) {
//Input vars :
$lat1 = $cord1['latitude'];
$lon1 = $cord1['longitude'];
$lat2 = $cord2['latitude'];
$lon2 = $cord2['longitude'];
/*
echo _BR_;
echo "$lat1 / $lon1"._BR_;
echo "$lat2 / $lon2"._BR_;
echo _BR_;
*/
//Const :
//$pi = 3.1415926535898;
// :=)
$pi= 3.1415926535897932384626433832795028841971693993751058;
//$r = 6367.4;//the radius of the Earth
//$r = 6366.8329383716631328393804536;
//$r='6367.5';
$r='6367.5';//Average radius
//$r='6378.14';//equoatorial radius
//$r='6356.8';//polar radius
//see http://www.wolframalpha.com/input/?i=radius+earth+ for more info:)
//Const :
//=> pi 3.1415926535897932384626433832795028841971693993751058;
//=> the radius of the Earth 6366.8329383716631328393804536;
//=> avg radius 6366.832, equoatorial radius 6378.14, polar radius 6356.8
//see http://www.wolframalpha.com
$pi = 3.1415926535898;
$r = '6366.832';
$this->radius_of_the_Earth=$r;
$this->pi=$pi;
$dist=$this->test__DDistance($lat1, $lon1, $lat2, $lon2);
$dist=$this->test__DDistance($lat1,$lon1,$lat2,$lon2);
$this->distanceKm = $dist;
$test7=$this->GML_distance($lat1, $lon1, $lat2, $lon2);
$this->calcAlg2 = $test7;
$this->azimutDeg = $test7[2];
$this->azimutBr = $test7[3];//bearing nn, ne, ss, se ...
......@@ -224,7 +232,6 @@ function calc_dist_az($cord1,$cord2) {
/*
TEST : ( 2 )
$dlon = $lon2 - $lon1;
......@@ -390,7 +397,7 @@ static function convlocator($locator) {
}
function setDebug($d){
$this->_debug.=$d;
$this->_debug.=$d._BR_;
}
function defineDestinationWithCoordinationGeographicalDegres($dst){
......@@ -438,9 +445,7 @@ static function convlocator($locator) {
}
function getAzimutDeg(){
return $this->azimutDeg;
}
function getSpotAzimutBr(){
......@@ -448,18 +453,18 @@ static function convlocator($locator) {
}
function getSpotAzimutInv(){
$rs = 360 - $this->azimutDeg;
return $rs;
}
function getDistanceKm(){
return $this->distanceKm;
}
function getDistanceKmV2(){
return round($this->calcAlg2[1],1);
}
function getPi(){
return $this->pi;
......@@ -473,10 +478,17 @@ static function convlocator($locator) {
function __construct(){
$locator='';
for($i=0;$i<func_num_args();$i++)$locator = func_get_arg(0);
if($this->CheckValidLocator($locator)){
if(!empty($locator) && $this->CheckValidLocator($locator)){
$this->defineSourceDegresWithLocator($locator);
}
}
function CheckValidLocator($locator){
......
......@@ -17,26 +17,108 @@
/**
* @author Bastien Barbe - CRX-FRAMEWORK
* @date 01/01/2005
* @revision 20/01/2019
* @revision 22/03/2019
* @lib picture
* @copyright see header
* @version 1.4
*/
define('DEBUG_crxGdPicture',0);
define('DEBUG_crxGdPicture',0);
class crxGdPicture{
var $finalPath = NULL;
var $debug = '';
function __construct(){
var $finalPath = NULL;
}
var $_stGenColor = array();
/**
* Create new ressource GD
* Param: type of the picture
* size of the picture (array)
*/
function __construct(){
}
function pctRgb2hex($col1, $col2, $percent) {
$rgb=array();
for($x=0;$x<3;$x++) {
$d=($col2[$x]-$col1[$x])*$percent+$col1[$x];
$rgb[]=(int)$d;
}
$hex = "#";
$hex .= str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT);
$hex .= str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT);
$hex .= str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT);
return $hex; // returns the hex value including the number sign (#)
}
function randomColor($format){
if($format=='html'){
$rand = str_pad(dechex(mt_rand(0x000000, 0xFFFFFF)), 6, 0, STR_PAD_LEFT);
//c2671a => 71a (extract this part to compare color)
$dg=substr($rand,4,3);
$h=hexdec($dg);
$range=65;
$ok=0;
$this->debug.='{ ';
$this->debug.='gen:<b>'.$h.' - '.$rand.'</b>';
if(empty($this->_stGenColor)){
$ok=1;
}
$failed=0;
foreach($this->_stGenColor as $k=>$v){
$test_max=$v+$range;
$test_min=$v-$range;
if(($v-$range)<0)$test_min=0;
if(($test_max>=$h) && ($h>=$test_min)){
$this->debug.='(value is ko, range:['. $test_min .' - '. $test_max.'][test:'.$v.'])';
$ok=0;
$failed=1;
break;
}
else{
$this->debug.='(value is ok, range:['. $test_min .' - '. $test_max.'][test:'.$v.'])';
$ok=1;
}
}
$this->debug.=' } ';
if($ok==0){
//return $this->randomColor();
$this->debug.=' > KO ';
}
//call recursive to generate new colors :
if($failed){
$rand = str_pad(dechex(mt_rand(0x000000, 0xFFFFFF)), 6, 0, STR_PAD_LEFT);
$dg=substr($rand,4,3);
$h=hexdec($dg);
//return $this->randomColor($format);
if($test_max>=$h){
$rand = str_pad(dechex(mt_rand(0x000000, 0xFFFFFF)), 6, 0, STR_PAD_LEFT);
$dg=substr($rand,4,3);
$h=hexdec($dg);
}
$this->debug.=' > NEW:<b>'.$h.' - '.$rand.'</b>';
}
$this->_stGenColor[] = $h;
return '#'.$rand;
}
}
function makePictureHeaders($type) {
header('Expires: Mon, 01 Jan 2000 00:00:00 GMT');
header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
......@@ -190,7 +272,6 @@ class crxGdPicture{
$this->dst_im = imagecreatetruecolor($destination_picture['w'],$destination_picture['h']);
if(DEBUG_crxGdPicture){echo "crxGdPicture::resizePicture => originalPictureType : ".$this->originalPictureType._BR_;}
if($this->originalPictureType=='jpeg'){
......@@ -208,29 +289,37 @@ class crxGdPicture{
if(DEBUG_crxGdPicture){
echo "crxGdPicture::resizePicture => doing imagejpeg => ".$rs._BR_;
echo "crxGdPicture::resizePicture => finalPath : ".$this->finalPath;
}
}
return true ;
}
if($this->originalPictureType=='gif'){
imagecopyresampled($this->dst_im,$this->src_im,0,0,0,0,
$rs=imagecopyresampled($this->dst_im,$this->src_im,0,0,0,0,
$destination_picture['w'],$destination_picture['h'],
$source_picture['w'],$source_picture['h']
);
ob_start();
imagegif($this->dst_im,$this->finalPath);// Save the new picture
ob_end_clean();
if(DEBUG_crxGdPicture){
echo "crxGdPicture::resizePicture => doing gif => ".$rs._BR_;
echo "crxGdPicture::resizePicture => finalPath : ".$this->finalPath;
}
return true ;
}
if($this->originalPictureType=='png'){
imagecopyresampled($this->dst_im,$this->src_im,0,0,0,0,
$rs=imagecopyresampled($this->dst_im,$this->src_im,0,0,0,0,
$destination_picture['w'],$destination_picture['h'],
$source_picture['w'],$source_picture['w']
$source_picture['w'],$source_picture['h']
);
ob_start();
imagepng($this->dst_im,$this->finalPath);// Save the new picture
ob_end_clean();
if(DEBUG_crxGdPicture){
echo "crxGdPicture::resizePicture => doing png => ".$rs._BR_;
echo "crxGdPicture::resizePicture => finalPath : ".$this->finalPath;
}
return true ;
}
......
......@@ -17,6 +17,134 @@ extends abstractDxClusterSpot{
var $xmlClusterShema = array();
var $debug = FALSE;
var $c_db = FALSE;
//todo
function getQsoDistanceAndAzimut(){
$dx = $this->callsignDx;
$send = $this->callsignSender;
$c=new hamCountry();
$c->setHamCallsign($dx);
$c->c_db=$this->c_db;
$c=new hamCountry();
$c->setHamCallsign($dx);
$c->c_db=$this->c_db;
$dx_id = $c->calcDxccSpiderID();
$debug_dx = $c->_debug_name_and_dxcc_id;
$rs=$c->dxccSpiderLookupInformation($dx_id);//$c->_dxcc_id
$this->debugMessage('Dx : '.$debug_dx.' - '.$rs['country_name'].' cq:'.$rs['country_cq_zone'].' iaru zone:'.$rs['country_iaru_zone']);
$this->_dx_info = $rs;
$c->setHamCallsign($send);
$send_id = $c->calcDxccSpiderID();
$debug_send = $c->_debug_name_and_dxcc_id;
$rs=$c->dxccSpiderLookupInformation($dx_id);//$c->_dxcc_id
//$this->debugMessage('Send : '.$debug_send);
$this->debugMessage('Send : '.$debug_dx.' - '.$rs['country_name'].' cq:'.$rs['country_cq_zone'].' iaru zone:'.$rs['country_iaru_zone']);
$test = new hamUser();
$test->setDbHandler($this->c_db);
//now try to find locator of the spot inside bdd :
if(locator::validLocator($this->locatorSender)){
$this->debugMessage('- My locator '.$this->locatorSender.' is ok.');
$locator['sender']=true;
$send_loc=$this->locatorSender;
}else{
$send_loc=$test->getLocator($send);
if(locator::validLocator($send_loc)){
$this->debugMessage('- My locator '.$this->locatorSender.' is ok (retreive from db),'.$send_loc);
$locator['sender']=true;
}
}
if(isset($this->locatorDx) && locator::validLocator($this->locatorDx)){
$this->debugMessage('- Dx locator is ok.');
$dx_loc=$this->locatorDx;
$locator['dx']=true;
}else{
$dx_loc=$test->getLocator($dx);
if(locator::validLocator($dx_loc)){
$this->debugMessage('- Dx locator is ok (retreive from db),'.$dx_loc);
$locator['sender']=true;
}else{
$this->debugMessage('- Cannot found Dx locator we \'ll use latitude and longitude of Capital City. ');
}
}
$c = new hamCountry();
$c->c_db=$this->c_db;
$dxcoor=$c->getDxccLatitudeAndLongitude($dx_id);
$sendcoor=$c->getDxccLatitudeAndLongitude($send_id);
/**
* If locator sender is correct we used it to create
* locator instance :
*/
if($send_loc){
$locator_info = new locator(strtoupper(trim($send_loc)));
$locator_info->defineSourceDegresWithLocator(strtoupper(trim($send_loc)));
$this->debugMessage('- Coord SND: '.round($locator_info->cmpLat,2).' / '.round($locator_info->cmpLon,2));
}
else{
$locator_info = new locator('');
$locator_info -> defineSourceWithCoordinationGeographicalDegres($sendcoor);
$this->debugMessage('- Coord SND: '.$sendcoor['Dxcc_latitude'].' / '.$sendcoor['Dxcc_longitude']);
}
if($dx_loc){
$locator_info->defineDestinationDegresWithAlocator(strtoupper(trim($dx_loc)));
$this->debugMessage('- Coord DX ('.$dx_loc.'): '.round($locator_info->cmpLat,2).' / '.round($locator_info->cmpLon,2));
}
else{
$locator_info->defineDestinationWithCoordinationGeographicalDegres($dxcoor);
$this->debugMessage('- (no locator) Coord DX: '.$dxcoor['Dxcc_latitude'].' / '.$dxcoor['Dxcc_longitude']);
}
$locator_info ->calcAzimutAndDistance();
$azimut = $locator_info ->getAzimutDeg();
$distance = $locator_info -> getDistanceKmV2();//getDistanceKm();
$azimut_inv = $locator_info ->getSpotAzimutInv();
$azimutBr = $locator_info ->getSpotAzimutBr();
$_rote = $locator_info ->getRadiusOfTheEarth();
$_pi = $locator_info ->getPi();
/*
if(is_nan($azimut)){
return "";
}
*/
$this->_coordComputed = array(
'source'=>$locator_info ->ArraySourceLocatorDegres,
'destination'=>$locator_info ->ArrayDestinationLocatorDegres
);
$this->_azimut_inv = $azimut_inv;//azm LP
$this->_azimut = $azimut;//azm SP
$this->_distance = $distance;
$this->_azimutBr = $azimutBr;
$this->_rote = $_rote;
$this->_pi = $_pi;
$result=null;
$result .= ''.$azimut.'&deg;/';
$result .= ''.$azimutBr.'/';
$result .= round($distance,1).'km';
return "$result";
}
function getDxClusterStatsDxSpotBestTimeForDx(
$time_select=array('start','end'),
......
......@@ -211,7 +211,6 @@ class dxClusterSpot {
}
$s->computeGeoInformation();