Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
MetaGer
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
41
Issues
41
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
Packages
Packages
Container Registry
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
open-source
MetaGer
Commits
85475d75
Commit
85475d75
authored
Dec 02, 2019
by
Aria
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replaced full path specification with usage of config_path()
parent
3f336783
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
+23
-23
app/Console/Commands/UpdateKelkooFeed.php
app/Console/Commands/UpdateKelkooFeed.php
+23
-23
No files found.
app/Console/Commands/UpdateKelkooFeed.php
View file @
85475d75
...
...
@@ -23,12 +23,12 @@ class UpdateKelkooFeed extends Command
/**
*
*/
protected
$url
=
"ftpkelkoo.kelkoo.net"
;
protected
$port
=
21
;
protected
$remoteFilePath
=
"/catalog/de/"
;
protected
$localFeedFilePath
=
"config
/KelkooFeeds/"
;
protected
$localExtractedFilePath
=
"
config
/KelkooFeeds/ExtractedFeeds/"
;
protected
$unzippedFileName
=
"Catalogfeed_full"
;
protected
$url
=
"ftpkelkoo.kelkoo.net"
;
protected
$port
=
21
;
protected
$remoteFilePath
=
"/catalog/de/"
;
protected
$localFeedFilePath
=
"
/KelkooFeeds/"
;
protected
$localExtractedFilePath
=
"/KelkooFeeds/ExtractedFeeds/"
;
protected
$unzippedFileName
=
"Catalogfeed_full"
;
/**
* Create a new command instance.
...
...
@@ -57,10 +57,10 @@ class UpdateKelkooFeed extends Command
private
function
deleteOldArchives
()
{
$archivesInDirectory
=
scandir
(
$this
->
localFeedFilePath
);
$archivesInDirectory
=
scandir
(
config_path
()
.
$this
->
localFeedFilePath
);
foreach
(
$archivesInDirectory
as
$file
)
{
if
(
is_file
(
$this
->
localFeedFilePath
.
"/"
.
$file
))
{
unlink
(
$this
->
localFeedFilePath
.
"/"
.
$file
);
if
(
is_file
(
config_path
()
.
$this
->
localFeedFilePath
.
"/"
.
$file
))
{
unlink
(
config_path
()
.
$this
->
localFeedFilePath
.
"/"
.
$file
);
}
}
}
...
...
@@ -70,18 +70,18 @@ class UpdateKelkooFeed extends Command
mkdir
(
'config/KelkooFeeds'
,
0777
,
true
);
}
$connection
=
ftp_connect
(
$this
->
url
,
$this
->
port
);
if
(
!
$connection
)
{
if
(
$connection
===
FALSE
)
{
Log
::
error
(
"Could not connect to
$this->url
"
);
return
;
}
else
{
if
(
ftp_login
(
$connection
,
env
(
"kelkoo_username"
),
env
(
"kelkoo_pass"
)))
{
$contents
=
ftp_nlist
(
$connection
,
$this
->
remoteFilePath
);
foreach
(
$contents
as
$content
)
{
if
(
ftp_get
(
$connection
,
$this
->
localFeedFilePath
.
basename
(
$content
)
,
$this
->
remoteFilePath
.
basename
(
$content
)
,
FTP_BINARY
))
{
echo
"File transfer successful - "
.
$this
->
localFeedFilePath
.
basename
(
$content
)
.
"
\n
"
;
if
(
ftp_get
(
$connection
,
config_path
()
.
$this
->
localFeedFilePath
.
basename
(
$content
)
,
$this
->
remoteFilePath
.
basename
(
$content
)
,
FTP_BINARY
))
{
echo
"File transfer successful - "
.
config_path
()
.
$this
->
localFeedFilePath
.
basename
(
$content
)
.
"
\n
"
;
}
else
{
echo
"There was an error while downloading
$this->localFeedFilePath
"
.
basename
(
$content
)
.
"
\n
"
;
Log
::
error
(
"Error while downloading
$this->localFeedFilePath
"
.
basename
(
$content
)
.
"
\n
"
);
echo
"There was an error while downloading
config_path() .
$this->localFeedFilePath
"
.
basename
(
$content
)
.
"
\n
"
;
Log
::
error
(
"Error while downloading
config_path() .
$this->localFeedFilePath
"
.
basename
(
$content
)
.
"
\n
"
);
return
;
}
}
...
...
@@ -96,11 +96,11 @@ class UpdateKelkooFeed extends Command
* Calculates MD5 values for the downloaded archives and verifies their integrity with the included "feeds.md5" file
*/
private
function
checkMD5
()
{
$archivesInDirectory
=
scandir
(
$this
->
localFeedFilePath
);
$archivesInDirectory
=
scandir
(
config_path
()
.
$this
->
localFeedFilePath
);
$archiveFileMatches
=
preg_grep
(
"/[\w\d]*Catalog[\S.]*\.xml\.gz/i"
,
$archivesInDirectory
);
foreach
(
$archiveFileMatches
as
$archiveFile
)
{
$feed_md5
=
md5_file
(
$this
->
localFeedFilePath
.
"/"
.
$archiveFile
);
$md5_file_content
=
file_get_contents
(
$this
->
localFeedFilePath
.
"feeds.md5"
);
$feed_md5
=
md5_file
(
config_path
()
.
$this
->
localFeedFilePath
.
"/"
.
$archiveFile
);
$md5_file_content
=
file_get_contents
(
config_path
()
.
$this
->
localFeedFilePath
.
"feeds.md5"
);
if
(
$md5_file_content
===
false
)
{
Log
:
error
(
"Could not find
\"
feeds.md5
\"
file"
);
return
false
;
...
...
@@ -117,21 +117,21 @@ class UpdateKelkooFeed extends Command
* Extracts the previously downloaded archives into one .xml file and after that deletes the old previous one
*/
private
function
extractReplaceFeedFiles
()
{
$archivesInDirectory
=
scandir
(
$this
->
localFeedFilePath
);
$archivesInDirectory
=
scandir
(
config_path
()
.
$this
->
localFeedFilePath
);
$archiveFileMatches
=
preg_grep
(
"/[\w\d]*Catalog[\S.]*\.xml\.gz/i"
,
$archivesInDirectory
);
$oldFeedFilesInDirectory
=
scandir
(
$this
->
localExtractedFilePath
);
$oldFeedFilesInDirectory
=
scandir
(
config_path
()
.
$this
->
localExtractedFilePath
);
$file
=
fopen
(
$this
->
localExtractedFilePath
.
$this
->
unzippedFileName
.
"_"
.
time
()
.
".xml"
,
"w"
);
$file
=
fopen
(
config_path
()
.
$this
->
localExtractedFilePath
.
$this
->
unzippedFileName
.
"_"
.
time
()
.
".xml"
,
"w"
);
foreach
(
$archiveFileMatches
as
$archiveFile
)
{
$unzipped
=
gzdecode
(
file_get_contents
(
$this
->
localFeedFilePath
.
$archiveFile
));
$unzipped
=
gzdecode
(
file_get_contents
(
config_path
()
.
$this
->
localFeedFilePath
.
$archiveFile
));
fwrite
(
$file
,
$unzipped
);
}
fclose
(
$file
);
foreach
(
$oldFeedFilesInDirectory
as
$oldFeedFile
)
{
if
(
is_file
(
$this
->
localExtractedFilePath
.
"/"
.
$oldFeedFile
))
{
unlink
(
$this
->
localExtractedFilePath
.
"/"
.
$oldFeedFile
);
if
(
is_file
(
config_path
()
.
$this
->
localExtractedFilePath
.
"/"
.
$oldFeedFile
))
{
unlink
(
config_path
()
.
$this
->
localExtractedFilePath
.
"/"
.
$oldFeedFile
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment