Register | Login
Attackpoint - performance and training tools for orienteering athletes

Training Log Archive: edwarddes

In the 7 days ending Sep 23, 2017:


«»
0:00
0:00
» now
SuMoTuWeThFrSa

Wednesday Sep 20, 2017 #

Note

EventReg Daily WTF:

The generated conf_num is used to join across a few tables. Why not just use the id column of the tables instead? Also note that db_id just rolled over 40000. So much fail in this code.


/**
* get_conf_num($db_id,$reg_type)
* creates a conf number based on:
* two digit year
* three digit julian date
* oregrun.id from the blank record created for this orienteer
* reg_type
* @param int $db_id, int $reg_type
* @return int conf_num
*/
public function get_conf_num($db_id,$reg_type)
{
// $filename = 'assets/conf_num/conf_num.dat';
// if (($fp = fopen($filename,"r+")) === FALSE) {
// echo 'Failed to open ' . $filename;
// } else {
// $num = trim(fgets($fp, 16));
// $conf_num =
sprintf("%d%03d%04d",date("Y")-2000,date("z"),$num);
// fseek($fp,0);
// ftruncate($fp,0);
// if ($num++ > 9999)
// $num = 1;
// fwrite($fp,$num);
// fclose($fp);
// }
// return $conf_num;
//just use the last four digits of the database ID
// if (($db_id) >= 10000 && ($db_id) < 100000):
// $db_id -= 10000;
// endif;
// if ($db_id >= 100000):
// $db_id -= 100000;
// endif;

if (($db_id) >= 10000 && ($db_id) < 20000):
$db_id -= 10000;
endif;
if (($db_id) >= 20000 && ($db_id) < 30000):
$db_id -= 20000;
endif;
if (($db_id) >= 30000 && ($db_id) < 40000):
$db_id -= 30000;
endif;
if ($db_id >= 100000):
$db_id -= 100000;
endif;


// $conf_num = sprintf("%d%03d%d%1d",date("Y")-2000,date("z"),$db_id,$reg_type);
$conf_num = sprintf("%d%03d%d%1d",date("Y")-2000,date("z"),$db_id,$reg_type);

return $conf_num;
}

« Earlier | Later »