예제 #1
0
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
예제 #2
0
 public function isValid($sValue)
 {
     $bIsExist = null;
     $nBBarcodeId = $sValue;
     $oModelSybase = new Admin_Model_Sybase();
     try {
         $sToday = $oModelSybase->getToday();
         if (isset($sToday)) {
             $bIsExist = $oModelSybase->findBorrowerBBarcode($nBBarcodeId);
         } else {
             throw new Zend_Exception();
         }
     } catch (Zend_Exception $e) {
         return true;
     }
     if ($bIsExist) {
         return true;
     } else {
         $this->_error(self::NOT_MATCH);
         return false;
     }
 }
예제 #3
0
 public function isValid($sValue, $aContext = null)
 {
     if (is_array($aContext) && isset($aContext["bbarcode_id"])) {
         $oModelSybase = new Admin_Model_Sybase();
         $sBorrowerId = $oModelSybase->checkBorrowerLogin($aContext["bbarcode_id"], $sValue);
         if ($sBorrowerId === false) {
             $this->_error(self::SYBASE);
             return false;
         }
     }
     if (null === self::$_filter) {
         self::$_filter = new Zend_Filter_Digits();
     }
     $sValueFiltered = self::$_filter->filter($sValue);
     $nLength = strlen($sValueFiltered);
     if ($nLength != 11) {
         $this->_error(self::LENGTH);
         return false;
     }
     $nErasmus = $sValue[6] + $sValue[7] + $sValue[8] + $sValue[9];
     if ($nErasmus == 0) {
         return true;
     }
     $nMod = 10;
     $nSum = 0;
     $aWeights = array(1, 3, 7, 9, 1, 3, 7, 9, 1, 3);
     preg_match_all("/\\d/", $sValueFiltered, $aDigits);
     $aValueFiltered = $aDigits[0];
     foreach ($aValueFiltered as $nDigit) {
         $nWeight = current($aWeights);
         $nSum += $nDigit * $nWeight;
         next($aWeights);
     }
     if ((10 - $nSum % $nMod == 10 ? 0 : 10) - $nSum % $nMod != $aValueFiltered[$nLength - 1]) {
         $this->_error(self::CHECKSUM, $sValueFiltered);
         return false;
     }
     return true;
 }