Commit b9b770fd authored by Imran Hussain's avatar Imran Hussain

Revert 664 and redo the fix but better

parent 8d1dbf1e
......@@ -16,7 +16,7 @@ function fetch_isbndb_data($isbn) {
function valid_isbn($isbn) {
return Validate_ISPN::isbn($isbn);
return (new Validate_ISPN)->isbn($isbn);
}
if ($session->groups[$permission]) {
......
......@@ -58,7 +58,7 @@
*/
class Validate_ISPN
{
public static function isbn($isbn)
function isbn($isbn)
{
if (preg_match("/[^0-9 IXSBN-]/", $isbn)) {
return false;
......@@ -91,7 +91,7 @@ class Validate_ISPN
* @author Helgi ormar <dufuz@php.net>
* @author Piotr Klaban <makler@man.torun.pl>
*/
public static function isbn13($isbn)
function isbn13($isbn)
{
if (preg_match("/[^0-9 ISBN-]/", $isbn)) {
return false;
......@@ -121,7 +121,7 @@ class Validate_ISPN
* @author Damien Seguy <dams@nexen.net>
* @author Helgi ormar <dufuz@php.net>
*/
public static function isbn10($isbn)
function isbn10($isbn)
{
static $weights_isbn = array(10,9,8,7,6,5,4,3,2);
......@@ -141,7 +141,7 @@ class Validate_ISPN
// Requires base class Validate
require_once 'Validate.php';
return Validate::_checkControlNumber($isbn, $weights_isbn, 11, 11);
return (new Validate)->_checkControlNumber($isbn, $weights_isbn, 11, 11);
}
......@@ -157,7 +157,7 @@ class Validate_ISPN
* @access public
* @author Piotr Klaban <makler@man.torun.pl>
*/
public static function issn($issn)
function issn($issn)
{
static $weights_issn = array(8,7,6,5,4,3,2);
......@@ -172,7 +172,7 @@ class Validate_ISPN
// Requires base class Validate
require_once 'Validate.php';
return Validate::_checkControlNumber($issn, $weights_issn, 11, 11);
return (new Validate)->_checkControlNumber($issn, $weights_issn, 11, 11);
}
/**
......@@ -191,7 +191,7 @@ class Validate_ISPN
* @access public
* @author Piotr Klaban <makler@man.torun.pl>
*/
public static function ismn($ismn)
function ismn($ismn)
{
static $weights_ismn = array(3,1,3,1,3,1,3,1,3);
......@@ -212,7 +212,7 @@ class Validate_ISPN
// Requires base class Validate
require_once 'Validate.php';
return Validate::_checkControlNumber($ismn, $weights_ismn, 10, 10);
return (new Validate)->_checkControlNumber($ismn, $weights_ismn, 10, 10);
}
/**
......@@ -228,7 +228,7 @@ class Validate_ISPN
* @access public
* @author David Grant <david@grant.org.uk>
*/
public static function isrc($isrc)
function isrc($isrc)
{
$isrc = str_replace(array('ISRC', '-', ' '), '', strtoupper($isrc));
if (!preg_match("/[A-Z]{2}[A-Z0-9]{3}[0-9]{7}/", $isrc)) {
......@@ -252,7 +252,7 @@ class Validate_ISPN
* @see Validate_ISPN::process()
* @author Piotr Klaban <makler@man.torun.pl>
*/
public static function ean8($ean)
function ean8($ean)
{
static $weights_ean8 = array(3,1,3,1,3,1,3);
return Validate_ISPN::process($ean, 8, $weights_ean8, 10, 10);
......@@ -272,7 +272,7 @@ class Validate_ISPN
* @see Validate_ISPN::process()
* @author Piotr Klaban <makler@man.torun.pl>
*/
public static function ean13($ean)
function ean13($ean)
{
static $weights_ean13 = array(1,3,1,3,1,3,1,3,1,3,1,3);
return Validate_ISPN::process($ean, 13, $weights_ean13, 10, 10);
......@@ -292,7 +292,7 @@ class Validate_ISPN
* @see Validate_ISPN::process()
* @author Piotr Klaban <makler@man.torun.pl>
*/
public static function ean14($ean)
function ean14($ean)
{
static $weights_ean14 = array(3,1,3,1,3,1,3,1,3,1,3,1,3);
return Validate_ISPN::process($ean, 14, $weights_ean14, 10, 10);
......@@ -312,7 +312,7 @@ class Validate_ISPN
* @see Validate_ISPN::process()
* @author Piotr Klaban <makler@man.torun.pl>
*/
public static function ucc12($ucc)
function ucc12($ucc)
{
static $weights_ucc12 = array(3,1,3,1,3,1,3,1,3,1,3);
return Validate_ISPN::process($ucc, 12, $weights_ucc12, 10, 10);
......@@ -332,7 +332,7 @@ class Validate_ISPN
* @see Validate_ISPN::process()
* @author Piotr Klaban <makler@man.torun.pl>
*/
public static function sscc($sscc)
function sscc($sscc)
{
static $weights_sscc = array(3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3);
return Validate_ISPN::process($sscc, 18, $weights_sscc, 10, 10);
......@@ -349,9 +349,9 @@ class Validate_ISPN
* @param array $weights holds the weight that will be used in calculations for the validation
* @return bool true if number is valid, otherwise false
* @access public
* @see Validate::_checkControlNumber()
* @see (new Validate)->_checkControlNumber()
*/
public static function process($data, $length, &$weights, $modulo = 10, $subtract = 0)
function process($data, $length, &$weights, $modulo = 10, $subtract = 0)
{
//$weights = array(3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3);
//$weights = array_slice($weights, 0, $length);
......@@ -365,7 +365,7 @@ class Validate_ISPN
// Requires base class Validate
require_once 'Validate.php';
return Validate::_checkControlNumber($data, $weights, $modulo, $subtract);
return (new Validate)->_checkControlNumber($data, $weights, $modulo, $subtract);
}
}
?>
......@@ -583,7 +583,7 @@ class Validate
return $ret;
}
public static function _modf($val, $div) {
function _modf($val, $div) {
if (function_exists('bcmod')) {
return bcmod($val, $div);
} elseif (function_exists('fmod')) {
......@@ -604,7 +604,7 @@ class Validate
*
* @access protected
*/
public static function _multWeights($number, &$weights) {
function _multWeights($number, &$weights) {
if (!is_array($weights)) {
return -1;
}
......@@ -634,7 +634,7 @@ class Validate
*
* @access protected
*/
public static function _getControlNumber($number, &$weights, $modulo = 10, $subtract = 0, $allow_high = false) {
function _getControlNumber($number, &$weights, $modulo = 10, $subtract = 0, $allow_high = false) {
// calc sum
$sum = Validate::_multWeights($number, $weights);
if ($sum == -1) {
......@@ -663,7 +663,7 @@ class Validate
*
* @access protected
*/
public static function _checkControlNumber($number, &$weights, $modulo = 10, $subtract = 0) {
function _checkControlNumber($number, &$weights, $modulo = 10, $subtract = 0) {
if (strlen($number) < count($weights)) {
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment