Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
jlopez
wicopa
Commits
1f82a2f0
Commit
1f82a2f0
authored
Mar 05, 2020
by
jlopez
Browse files
Big update
parent
d37f4a23
Changes
8
Hide whitespace changes
Inline
Side-by-side
dao/DBquery.php
View file @
1f82a2f0
...
...
@@ -57,25 +57,34 @@ class DBquery
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
$results
=
array
();
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
$d
=
new
Distribution
(
$row
[
'ID'
],
$row
[
'name'
],
$row
[
'version'
],
$row
[
'manager'
],
$row
[
'active'
]);
$d
=
new
Distribution
(
$row
[
'ID'
],
$row
[
'name'
],
$row
[
'version'
],
$row
[
'manager'
],
$row
[
'active'
]
,
$row
[
'vname'
]
);
array_push
(
$results
,
$d
);
}
return
$results
;
}
public
function
getVName
(
$name
,
$version
)
{
$sql
=
"SELECT vname FROM `Distrib` WHERE active = 1 AND `name`='
$name
' AND `version`='
$version
';"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
return
$row
[
'vname'
];
}
return
""
;
}
public
function
getActiveDistributions
()
{
$sql
=
"SELECT * FROM `Distrib` WHERE active = 1 ORDER BY `Distrib`.`name` ASC;"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
$results
=
array
();
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
$d
=
new
Distribution
(
$row
[
'ID'
],
$row
[
'name'
],
$row
[
'version'
],
$row
[
'manager'
],
$row
[
'active'
]);
$d
=
new
Distribution
(
$row
[
'ID'
],
$row
[
'name'
],
$row
[
'version'
],
$row
[
'manager'
],
$row
[
'active'
]
,
$row
[
'vname'
]
);
array_push
(
$results
,
$d
);
}
return
$results
;
}
public
function
getActiveDistributionsFullName
()
{
$sql
=
"SELECT name,version FROM `Distrib` WHERE active = 1 ORDER BY `Distrib`.`name` ASC;"
;
$sql
=
"SELECT name,version
,vname
FROM `Distrib` WHERE active = 1 ORDER BY `Distrib`.`name` ASC;"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
$results
=
array
();
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
...
...
getPackages.php
View file @
1f82a2f0
...
...
@@ -8,6 +8,7 @@
require_once
"./dao/DBquery.php"
;
require_once
"./package.php"
;
$db
=
new
DBquery
();
...
...
@@ -29,9 +30,10 @@ if(isset($_GET['filter'])) {
$filter
=
$_GET
[
'filter'
];
}
$patternName
=
fals
e
;
$patternDescription
=
fals
e
;
$patternName
=
tru
e
;
$patternDescription
=
tru
e
;
/*
if(isset($_GET['patternName'])) {
if($_GET['patternName'] == "true") {
$patternName = true;
...
...
@@ -42,16 +44,45 @@ if(isset($_GET['patternDescription'])) {
if($_GET['patternDescription'] == "true") {
$patternDescription = true;
}
}
}
*/
$limit
=
"25"
;
$limit
=
20
;
if
(
isset
(
$_GET
[
'limit'
]))
{
/*
if(isset($_GET['limit'])) {
$limit = $_GET['limit'];
}
}*/
$result
=
array
();
$result
=
$db
->
getPackages
(
$distrib
,
$filter
,
$patternName
,
$patternDescription
,
$limit
);
var_dump
(
$distrib
);
if
(
strpos
(
$distrib
,
':'
)
!==
false
)
{
$os
=
explode
(
":"
,
$distrib
);
$os_name
=
$os
[
0
];
$version_num
=
$os
[
1
];
$version_name
=
$db
->
getVName
(
$os_name
,
$version_num
);
$result
=
findDistributionPackage
(
$os_name
,
$version_num
,
$version_name
,
$filter
,
$limit
,
false
);
}
else
{
if
(
$distrib
==
"Conda"
)
{
$result
=
findCondaPackage
(
$distrib
,
$version_num
,
$version_name
,
$filter
,
$limit
,
false
);
}
else
if
(
$distrib
==
"Rubygems"
)
{
$result
=
findRubyPackage
(
$distrib
,
$version_num
,
$version_name
,
$filter
,
$limit
,
false
);
}
else
if
(
$distrib
==
"NPM"
)
{
$result
=
findNPMPackage
(
$distrib
,
$version_num
,
$version_name
,
$filter
,
$limit
,
false
);
}
else
if
(
$distrib
==
"CPAN"
)
{
$result
=
findCPANPackage
(
$distrib
,
$version_num
,
$version_name
,
$filter
,
$limit
,
false
);
}
else
if
(
$distrib
==
"CRAN"
)
{
$result
=
findRPackage
(
$distrib
,
$version_num
,
$version_name
,
$filter
,
$limit
,
false
);
}
else
{
$result
=
$db
->
getPackages
(
$distrib
,
$filter
,
$patternName
,
$patternDescription
,
$limit
);
}
}
echo
'
<div class="container">
...
...
inc/js/wicopa.js
View file @
1f82a2f0
...
...
@@ -517,7 +517,8 @@ function generate_container() {
for
(
var
i
=
0
;
i
<
SELECTED_PACKAGES
[
"
CPAN
"
].
length
;
i
++
)
{
var
version
=
"
@
"
+
SELECTED_PACKAGES
[
"
CPAN
"
][
i
][
1
];
//var version = "@"+SELECTED_PACKAGES["CPAN"][i][1];
var
version
=
""
;
if
(
version
===
"
@undef
"
)
{
version
=
""
...
...
@@ -694,7 +695,8 @@ function showPackage(distribName) {
var
str
=
document
.
getElementById
(
"
find
"
+
distribName
+
"
Packages
"
).
value
;
var
limit
=
document
.
getElementById
(
"
limit
"
+
distribName
).
value
;
//var limit = document.getElementById("limit"+distribName).value;
var
limit
=
20
;
if
(
str
==
""
)
{
document
.
getElementById
(
"
containPackages
"
+
distribName
).
innerHTML
=
""
;
...
...
@@ -711,11 +713,15 @@ function showPackage(distribName) {
}
};
var
patternName
=
document
.
getElementById
(
"
pattern
"
+
distribName
+
"
Name
"
).
checked
;
var
patternDescription
=
document
.
getElementById
(
"
pattern
"
+
distribName
+
"
Description
"
).
checked
;
//var patternName = document.getElementById("pattern"+distribName+"Name").checked;
//var patternDescription = document.getElementById("pattern"+distribName+"Description").checked;
var
patternName
=
true
;
var
patternDescription
=
true
;
//xmlhttp.open("GET","get"+distribName+"Packages.php?distrib="+distrib+"&filter="+str+"&patternName="+patternName+"&patternDescription="+patternDescription+"&limit="+limit,true);
xmlhttp
.
open
(
"
GET
"
,
"
getPackages.php?distrib=
"
+
distrib
+
"
&filter=
"
+
str
+
"
&patternName=
"
+
patternName
+
"
&patternDescription=
"
+
patternDescription
+
"
&limit=
"
+
limit
,
true
);
console
.
log
(
"
getPackages.php?distrib=
"
+
distrib
+
"
&filter=
"
+
str
+
"
&patternName=
"
+
patternName
+
"
&patternDescription=
"
+
patternDescription
+
"
&limit=
"
+
limit
);
xmlhttp
.
send
();
}
}
\ No newline at end of file
inc/php/printPanel.php
View file @
1f82a2f0
...
...
@@ -71,7 +71,8 @@ function printPanel($name) {
echo
'
<label for="find'
.
$name
.
'Packages">Find packages with pattern :</label>
<input type="email" class="form-control" id="find'
.
$name
.
'Packages">
<!--
<div class="form-check">
<input type="checkbox" class="form-check-input" id="pattern'
.
$name
.
'Name" checked>
<label class="form-check-label" for="pattern'
.
$name
.
'Name">Pattern on name</label>
...
...
@@ -80,10 +81,11 @@ function printPanel($name) {
<div class="form-check">
<input type="checkbox" class="form-check-input" id="pattern'
.
$name
.
'Description" checked>
<label class="form-check-label" for="pattern'
.
$name
.
'Description">Pattern on description</label>
</div>
</div>
-->
<br/>
<!--
<div class="form-group">
<label for="limit'
.
$name
.
'" class="font-check-label">Max found :</label>
<select class="custom-select" id="limit'
.
$name
.
'">
...
...
@@ -95,7 +97,7 @@ function printPanel($name) {
<option value="100">200</option>
<option value="1000000000">all</option>
</select>
</div>
</div>
-->
<div class="form-group">
<button type="button" class="btn btn-primary" onclick="showPackage(\''
.
$name
.
'\')">Search</button>
...
...
manage.php
View file @
1f82a2f0
...
...
@@ -70,7 +70,6 @@ require_once "./inc/php/buildHeader.php";
<th>
Parent
</th>
<th>
Packages
</th>
<th>
Save
</th>
<th>
Update
</th>
</tr>
</thead>
<tbody
id=
"TableSection"
>
...
...
@@ -97,7 +96,6 @@ require_once "./inc/php/buildHeader.php";
echo
'<td>'
.
$section
->
parent
.
'</td>'
;
echo
'<td>'
.
$db
->
getNumberPackage
(
$section
->
name
)
.
'</td>'
;
echo
'<td>'
.
'<button type="submit" class="btn btn-info btn-sm">save</button>'
.
'</td>'
;
echo
'<td>'
.
'<a href="#" class="btn btn-warning btn-sm">update</button>'
.
'</td>'
;
echo
'</tr></form>'
;
foreach
(
$db
->
getAllSectionWhithParent
(
$section
->
name
)
as
$subsection
)
{
...
...
@@ -117,9 +115,7 @@ require_once "./inc/php/buildHeader.php";
echo
'<td>'
.
'<input id="number" name="arrangement" class="form-control" type="number" value="'
.
$subsection
->
arrangement
.
'">'
.
'</td>'
;
echo
'<td>'
.
$subsection
->
parent
.
'</td>'
;
echo
'<td>'
.
$db
->
getNumberPackage
(
$subsection
->
name
)
.
'</td>'
;
echo
'<td>'
.
'<button type="submit" class="btn btn-info btn-sm">save</button>'
.
'</td>'
;
echo
'<td>'
.
'<a href="#" class="btn btn-warning btn-sm">update</button>'
.
'</td>'
;
echo
'<td>'
.
'<button type="submit" class="btn btn-info btn-sm">save</button>'
.
'</td>'
;
echo
'</tr></form>'
;
}
}
...
...
model/Distribution.php
View file @
1f82a2f0
...
...
@@ -17,6 +17,7 @@ class Distribution
var
$manager
=
""
;
var
$active
=
0
;
var
$state
=
0
;
var
$vname
=
""
;
/**
* Section constructor.
...
...
@@ -24,13 +25,14 @@ class Distribution
* @param string $name
* @param int $value
*/
public
function
__construct
(
$ID
,
$name
,
$version
,
$manager
,
$active
)
public
function
__construct
(
$ID
,
$name
,
$version
,
$manager
,
$active
,
$vname
)
{
$this
->
ID
=
$ID
;
$this
->
name
=
$name
;
$this
->
version
=
$version
;
$this
->
manager
=
$manager
;
$this
->
active
=
$active
;
$this
->
vname
=
$vname
;
}
public
function
getFullName
()
...
...
@@ -39,13 +41,13 @@ class Distribution
}
public
function
getInsert
()
{
return
"INSERT INTO Distrib (name, version, manager, active)
VALUES ('
$this->name
', '
$this->version
', '
$this->manager
', '
$this->active
');"
;
return
"INSERT INTO Distrib (name, version, manager, active
, vname
)
VALUES ('
$this->name
', '
$this->version
', '
$this->manager
', '
$this->active
'
, '
$this->vname
'
);"
;
}
public
function
getUpdate
()
{
return
"UPDATE Distrib
SET name='
$this->name
', version='
$this->version
', manager='
$this->manager
', active=
$this->active
SET name='
$this->name
', version='
$this->version
', manager='
$this->manager
', active=
$this->active
, vname=
$this->vname
WHERE ID = '
$this->ID
';"
;
}
...
...
@@ -58,6 +60,7 @@ class Distribution
$this
->
name
=
utf8_decode
(
$db
->
escape
(
$this
->
name
));
$this
->
version
=
utf8_decode
(
$db
->
escape
(
$this
->
version
));
$this
->
manager
=
utf8_decode
(
$db
->
escape
(
$this
->
manager
));
$this
->
vname
=
utf8_decode
(
$db
->
escape
(
$this
->
vname
));
}
public
function
activateUpdate
()
{
...
...
package.php
0 → 100644
View file @
1f82a2f0
<?php
require_once
(
__DIR__
.
'/model/Package.php'
);
function
cleanValue
(
$value
)
{
$value
=
str_replace
(
"
\n
"
,
""
,
$value
);
$value
=
str_replace
(
"
\r
"
,
""
,
$value
);
$value
=
str_replace
(
"
\t
"
,
""
,
$value
);
$value
=
str_replace
(
" "
,
""
,
$value
);
return
$value
;
}
function
getDocument
(
$url
)
{
$opts
=
array
(
'http'
=>
array
(
'method'
=>
"GET"
,
'header'
=>
"Accept-language: en
\r\n
"
)
);
$context
=
stream_context_create
(
$opts
);
$content
=
file_get_contents
(
$url
,
false
,
$context
);
$doc
=
new
DOMDocument
();
$doc
->
loadHtml
(
$content
);
return
$doc
;
}
function
findDistributionPackage
(
$os_name
,
$version_num
,
$version_name
,
$keyword
,
$limit
,
$onlyname
)
{
if
(
$os_name
==
"ubuntu"
||
$os_name
==
"debian"
)
{
return
findUbuntuDebianPackage
(
$os_name
,
$version_num
,
$version_name
,
$keyword
,
$limit
,
$onlyname
);
}
else
if
(
$os_name
==
"fedora"
||
$os_name
==
"centos"
)
{
return
findFedoraCentosPackage
(
$os_name
,
$version_num
,
$version_name
,
$keyword
,
$limit
,
$onlyname
);
}
else
if
(
$os_name
==
"alpine"
)
{
return
findAlpinePackages
(
$os_name
,
$version_num
,
$version_name
,
$keyword
,
$limit
,
$onlyname
);
}
}
function
findFedoraCentosPackage
(
$os_name
,
$version_num
,
$version_name
,
$keyword
,
$limit
,
$onlyname
)
{
$results
=
array
();
$keyword_first
=
strtolower
(
$keyword
[
0
]);
$url_packages
=
""
;
if
(
$os_name
==
"fedora"
)
{
$url_packages
=
"https://dl.fedoraproject.org/pub/fedora/linux/releases/"
.
$version_num
.
"/Everything/source/tree/Packages/"
.
$keyword_first
.
"/"
;
}
else
if
(
$os_name
==
"centos"
)
{
$url_packages
=
"http://mirror.centos.org/centos/"
.
$version_num
.
"/os/x86_64/Packages/"
;
}
$doc
=
getDocument
(
$url_packages
);
$as
=
$doc
->
getElementsByTagName
(
'a'
);
$size
=
$as
->
length
;
$index
=
0
;
for
(
$i
=
5
;
$i
<=
$size
;
$i
++
)
{
$value
=
$as
[
$i
]
->
nodeValue
;
if
(
$value
!=
null
)
{
$subject
=
$value
;
$pattern
=
"#(.*)-(.*)-(.*?)\.(.*)(\.rpm)#"
;
preg_match
(
$pattern
,
$subject
,
$matches
);
$name
=
$matches
[
1
];
$version
=
$matches
[
2
];
$pos
=
strpos
(
$name
,
$keyword
);
if
(
$pos
!==
false
)
{
$link
=
$url_packages
.
$value
;
$other
=
$os_name
.
":"
.
$version_num
;
$description
=
""
;
$package
=
new
Package
(
$name
,
$version
,
$description
,
$link
,
$other
);
$results
[]
=
$package
;
$index
++
;
if
(
$index
==
$limit
)
{
break
;
}
}
}
}
return
$results
;
}
function
findAlpinePackages
(
$os_name
,
$version_num
,
$version_name
,
$keyword
,
$limit
,
$onlyname
)
{
$results
=
array
();
$keyword
=
"*"
.
$keyword
.
"*"
;
$basic_url
=
"https://pkgs.alpinelinux.org/packages"
;
$url_packages
=
$basic_url
.
"?name="
.
$keyword
.
"&branch=v"
.
$version_num
.
"&repo=main&arch=x86_64"
;
$doc
=
getDocument
(
$url_packages
);
$tr
=
$doc
->
getElementsByTagName
(
'tr'
);
$size
=
$tr
->
length
;
$index
=
0
;
for
(
$i
=
1
;
$i
<=
$size
;
$i
++
)
{
$name
=
cleanValue
(
$$tr
[
$i
]
->
childNodes
[
1
]
->
nodeValue
);
$version
=
$tr
[
$i
]
->
childNodes
[
3
]
->
nodeValue
;
if
(
$name
!=
null
&&
$name
!=
""
)
{
$description
=
""
;
$link
=
$basic_url
.
"/v"
.
$version_num
.
"/main/x86_64/"
.
$name
;
$other
=
$os_name
.
":"
.
$version_num
;
$package
=
new
Package
(
$name
,
$version
,
$description
,
$link
,
$other
);
$results
[]
=
$package
;
$index
++
;
if
(
$index
==
$limit
)
{
break
;
}
}
}
return
$results
;
}
function
findUbuntuDebianPackage
(
$os_name
,
$version_num
,
$version_name
,
$keyword
,
$limit
,
$onlyname
)
{
$results
=
array
();
$filter
=
"all"
;
if
(
$onlyname
)
{
$filter
=
"names"
;
}
$basic_url
=
""
;
if
(
$os_name
==
"ubuntu"
)
{
$basic_url
=
"https://packages.ubuntu.com"
;
}
else
if
(
$os_name
==
"debian"
)
{
$basic_url
=
"https://packages.debian.org"
;
}
$url_packages
=
$basic_url
.
"/search?suite="
.
$version_name
.
"§ion=all&arch=any&keywords="
.
$keyword
.
"&searchon="
.
$filter
;
$doc
=
getDocument
(
$url_packages
);
$list
=
$doc
->
getElementById
(
'psearchres'
);
$names
=
$list
->
getElementsByTagName
(
'h3'
);
$uls
=
$list
->
getElementsByTagName
(
'ul'
);
$size
=
$names
->
length
;
if
(
$names
->
length
!=
$uls
->
length
)
{
$size
=
min
(
$names
->
length
,
$uls
->
length
);
}
$size
=
min
(
$size
,
$limit
);
for
(
$i
=
0
;
$i
<=
$size
;
$i
++
)
{
$name
=
substr
(
$names
[
$i
]
->
nodeValue
,
8
);
if
(
$name
)
{
$description
=
$uls
[
$i
]
->
childNodes
[
1
]
->
childNodes
[
1
]
->
nodeValue
;
$description
=
cleanValue
(
substr
(
$description
,
1
,
-
2
));
$version
=
$uls
[
$i
]
->
childNodes
[
1
]
->
childNodes
[
5
]
->
nodeValue
;
if
(
$version
==
null
)
{
$version
=
$uls
[
$i
]
->
childNodes
[
1
]
->
childNodes
[
4
]
->
nodeValue
;
}
if
(
$version
==
null
)
{
$version
=
$uls
[
$i
]
->
childNodes
[
1
]
->
childNodes
[
3
]
->
nodeValue
;
}
if
(
$version
==
null
)
{
$version
=
""
;
}
else
{
$version
=
explode
(
":"
,
$version
)[
0
];
}
$link
=
$basic_url
.
"/"
.
$version_name
.
"/"
.
$name
;
$other
=
$os_name
.
":"
.
$version_num
;
$package
=
new
Package
(
$name
,
$version
,
$description
,
$link
,
$other
);
$results
[]
=
$package
;
}
}
return
$results
;
}
//TODO finish
function
findPythonPackage
(
$os_name
,
$version_num
,
$version_name
,
$keyword
,
$limit
,
$onlyname
)
{
$results
=
array
();
$basic_url
=
"https://pypi.org/search/?q="
;
$url_packages
=
$basic_url
.
$keyword
;
$doc
=
getDocument
(
$url_packages
);
$tr
=
$doc
->
getElementsByTagName
(
'li'
);
$size
=
$tr
->
length
;
$index
=
0
;
for
(
$i
=
0
;
$i
<=
$size
;
$i
++
)
{
$vv
=
$tr
[
$i
]
->
getElementsByTagName
(
'span'
);
$name
=
$vv
[
1
];
}
$doc
=
getDocument
(
$url_packages
);
return
$results
;
}
function
findRPackage
(
$os_name
,
$version_num
,
$version_name
,
$keyword
,
$limit
,
$onlyname
)
{
$repos
=
""
;
if
(
$os_name
==
"CRAN"
)
{
$repos
=
"cran"
;
}
else
if
(
$os_name
==
"Bioconductor"
)
{
$repos
=
"bioc"
;
}
else
if
(
$os_name
==
"Rforge"
)
{
$repos
=
"rforge"
;
}
else
if
(
$os_name
==
"Github"
)
{
$repos
=
"github"
;
}
$basic_url
=
"https://rdrr.io/find/?repos="
.
$repos
.
"&fuzzy_slug="
;
$url_packages
=
$basic_url
.
$keyword
;
$doc
=
getDocument
(
$url_packages
);
$trs
=
$doc
->
getElementsByTagName
(
'tr'
);
$size
=
$trs
->
length
;
for
(
$i
=
1
;
$i
<=
$size
;
$i
++
)
{
var_dump
(
$trs
[
$i
]
->
childNodes
[
1
]
->
childNodes
[
0
]);
}
return
$results
;
}
function
findCPANPackage
(
$os_name
,
$version_num
,
$version_name
,
$keyword
,
$limit
,
$onlyname
)
{
$results
=
array
();
$basic_url
=
"https://metacpan.org/search?size="
.
$limit
.
"&q="
;
$url_packages
=
$basic_url
.
$keyword
;
$doc
=
getDocument
(
$url_packages
);
$bigs
=
$doc
->
getElementsByTagName
(
'big'
);
$spans
=
$doc
->
getElementsByTagName
(
'span'
);
$finder
=
new
DomXPath
(
$doc
);
$classname
=
"relatize"
;
$spans
=
$finder
->
query
(
"//*[contains(concat(' ', normalize-space(@class), ' '), '
$classname
')]"
);
$size
=
$bigs
->
length
-
1
;
for
(
$i
=
0
;
$i
<=
$size
;
$i
++
)
{
$splt
=
explode
(
" - "
,
$bigs
[
$i
]
->
nodeValue
);
$name
=
cleanValue
(
$splt
[
0
]);
$name
=
str_replace
(
" "
,
""
,
$name
);
$description
=
cleanValue
(
$splt
[
1
]);
$link
=
"https://metacpan.org/pod/"
.
$name
;
$version
=
""
;
$other
=
$spans
[
$i
]
->
childNodes
[
0
]
->
nodeValue
;
$package
=
new
Package
(
$name
,
$version
,
$description
,
$link
,
$other
);
$results
[]
=
$package
;
}
return
$results
;
}
function
findNPMPackage
(
$os_name
,
$version_num
,
$version_name
,
$keyword
,
$limit
,
$onlyname
)
{
$results
=
array
();
$basic_url
=
"https://www.npmjs.com/search?q="
;
$url_packages
=
$basic_url
.
$keyword
;
$doc
=
getDocument
(
$url_packages
);
$section
=
$doc
->
getElementsByTagName
(
'section'
);
$size
=
$section
->
length
;
$index
=
0
;
for
(
$i
=
0
;
$i
<=
$size
;
$i
++
)
{
$vv
=
$section
[
$i
]
->
childNodes
[
1
];
$name
=
$vv
->
childNodes
[
0
]
->
childNodes
[
0
]
->
nodeValue
;
$description
=
$vv
->
childNodes
[
2
]
->
childNodes
[
0
]
->
nodeValue
;
$version
==
""
;
if
(
$vv
->
childNodes
->
length
==
5
)
{
$version
=
$vv
->
childNodes
[
4
]
->
childNodes
[
1
]
->
nodeValue
;
}
else
if
(
$vv
->
childNodes
->
length
==
7
)
{
$version
=
$vv
->
childNodes
[
6
]
->
childNodes
[
1
]
->
nodeValue
;
}
$other
=
explode
(
" "
,
$version
);
$version
=
explode
(
" "
,
$version
)[
1
];
$other
=
$other
[
3
]
.
" "
.
$other
[
4
]
.
" "
.
$other
[
5
];
$link
=
"https://www.npmjs.com/package/"
.
$name
;
$package
=
new
Package
(
$name
,
$version
,
$description
,
$link
,
$other
);
$results
[]
=
$package
;
$index
++
;
if
(
$index
==
$limit
)
{
break
;
}
}
return
$results
;
}
function
findRubyPackage
(
$os_name
,
$version_num
,
$version_name
,
$keyword
,
$limit
,
$onlyname
)
{
$results
=
array
();
$basic_url
=
"https://rubygems.org/search?page=1&query="
;
$url_packages
=
$basic_url
.
$keyword
;
$doc
=
getDocument
(
$url_packages
);