Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sucs-site
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Moras
sucs-site
Commits
b9b770fd
Commit
b9b770fd
authored
9 years ago
by
Imran Hussain
Browse files
Options
Downloads
Patches
Plain Diff
Revert 664 and redo the fix but better
parent
8d1dbf1e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
components/libraryadmin.php
+1
-1
1 addition, 1 deletion
components/libraryadmin.php
lib/Validate/ISPN.php
+17
-17
17 additions, 17 deletions
lib/Validate/ISPN.php
lib/Validate/Validate.php
+4
-4
4 additions, 4 deletions
lib/Validate/Validate.php
with
22 additions
and
22 deletions
components/libraryadmin.php
+
1
−
1
View file @
b9b770fd
...
...
@@ -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
])
{
...
...
This diff is collapsed.
Click to expand it.
lib/Validate/ISPN.php
+
17
−
17
View file @
b9b770fd
...
...
@@ -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
);
}
}
?>
This diff is collapsed.
Click to expand it.
lib/Validate/Validate.php
+
4
−
4
View file @
b9b770fd
...
...
@@ -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
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment