cyklokoalicia / OpenSourceBikeShare

The world's first low-cost and open source bike sharing system. (new version in development, use working "breakthrough" release instead!)
http://opensourcebikeshare.com/
GNU General Public License v3.0
169 stars 71 forks source link

Only change the lock code every few rides. #119

Open ewooonk opened 7 years ago

ewooonk commented 7 years ago

Although this turned out to be not practical in our case, it might be helpful for others.

   $codereset=sprintf("%04d",rand(1,4));
   if ($codereset == 3)
   {
       { $newCode = sprintf("%04d",rand(100,9900));
       }
   }
   if ($codereset != 3)
   {
       { $newCode=$currentCode;
       }

   }
   // do not create a code with more than one leading zero or more than two leading 9s (kind of unusual/unsafe).
   if ($force==FALSE)
      {
      if ($currentUser==$userId)
         {
         response(_('You already rented bike')." ".$bikeNum.". "._('Code is')." ".$currentCode.".",ERROR);
         return;
         }
      if ($currentUser!=0)
         {
         response(_('Bike')." ".$bikeNum." "._('is already rented').".",ERROR);
         return;
         }
      }
   if ($codereset == 3)
   {
       { $message='<h3>'._('Bike').' '.$bikeNum.': <span class="label label-primary">'._('Open with code').' '.$currentCode.'.</span></h3>'._('Change code immediately to').' <span class="label label-default">'.$newCode.'</span><br />'._('(open, move pin on the bottom to position B, set new code, move pin back to position A)').'.';
       }
   }
   if ($codereset != 3)
   {
       { $message='<h3>'._('Bike').' '.$bikeNum.': <span class="label label-primary">'._('Open with code').' '.$currentCode.'.</span></h3>'._('You do not need to change the code').' .';
       }
   }
nekromoff commented 7 years ago

Thanks.

Please, @jozefbalun add this as a config option to the new Laravel version as well as implement it accordingly (or assign to @miroc).

Reasoning: some systems may want to change the code only from time to time, e.g. every 10th ride or such.