Dotclear 2.26
Loading...
Searching...
No Matches
dcUpdate Class Reference

Public Member Functions

 __construct (string $url, string $subject, string $version, string $cache_dir)
 
 check (string $version, bool $nocache=false)
 
 getVersionInfo (bool $nocache=false)
 
 getVersion ()
 
 getFileURL ()
 
 getInfoURL ()
 
 getChecksum ()
 
 getPHPVersion ()
 
 getWarning ()
 
 getNotify ()
 
 getForcedFiles ()
 
 setForcedFiles (... $args)
 
 setNotify ($n)
 
 checkIntegrity (string $digests_file, string $root)
 
 getBadFiles ()
 
 download (string $dest)
 
 checkDownload (string $zip)
 
 backup (string $zip_file, string $zip_digests, string $root, string $root_digests, string $dest)
 
 performUpgrade (string $zip_file, string $zip_digests, string $zip_root, string $root, string $root_digests)
 

Data Fields

const ERR_FILES_CHANGED = 101
 
const ERR_FILES_UNREADABLE = 102
 
const ERR_FILES_UNWRITALBE = 103
 

Protected Member Functions

 getNewFiles (array $cur_digests, array $new_digests)
 
 readVersion (string $str)
 
 md5sum (string $root, string $digests_file)
 
 parseLine (&$v, $k, $n)
 

Static Protected Member Functions

static md5_check (string $filename, string $md5)
 

Protected Attributes

 $url
 
 $subject
 
 $version
 
 $cache_file
 
 $version_info
 
 $cache_ttl = '-6 hours'
 
 $forced_files = []
 
 $bad_files = []
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( string  $url,
string  $subject,
string  $version,
string  $cache_dir 
)

Constructor

Parameters
string$urlVersions file URL
string$subjectSubject to check
string$versionVersion channel
string$cache_dirDirectory cache path

References $subject, $url, and $version.

Member Function Documentation

◆ check()

check ( string  $version,
bool  $nocache = false 
)

Checks for Dotclear updates. Returns latest version if available or false.

Parameters
string$versionCurrent version to compare
bool$nocacheForce checking
Returns
mixed Latest version if available

References $version, getVersion(), and getVersionInfo().

◆ getVersionInfo()

getVersionInfo ( bool  $nocache = false)

Gets the version information.

Parameters
bool$nocacheThe no cache flag
Exceptions
Exception
Returns
mixed

References DC_QUERY_TIMEOUT, and readVersion().

Referenced by check().

◆ getVersion()

getVersion ( )

Gets the version.

Returns
string|null The version.

Referenced by check().

◆ getFileURL()

getFileURL ( )

Gets the file url.

Returns
string|null The file url.

Referenced by download().

◆ getInfoURL()

getInfoURL ( )

Gets the information url.

Returns
string|null The information url.

◆ getChecksum()

getChecksum ( )

Gets the checksum.

Returns
string|null The checksum.

Referenced by checkDownload().

◆ getPHPVersion()

getPHPVersion ( )

Gets the php version.

Returns
string|null The php version.

◆ getWarning()

getWarning ( )

Gets the warning flag.

Returns
bool The warning.

◆ getNotify()

getNotify ( )

Gets the notify flag.

Returns
bool The notify.

◆ getForcedFiles()

getForcedFiles ( )

Gets the forced files.

Returns
array The forced files.

References $forced_files.

◆ setForcedFiles()

setForcedFiles (   $args)

Sets the forced files.

Parameters
mixed...$args The arguments

◆ setNotify()

setNotify (   $n)

Sets the notify flag.

Parameters
mixed$nThe new value

◆ checkIntegrity()

checkIntegrity ( string  $digests_file,
string  $root 
)

Check integrity

Parameters
string$digests_fileThe digests file
string$rootThe root
Exceptions
ExceptionIf some files have changed
Returns
bool

References md5sum().

◆ getBadFiles()

getBadFiles ( )

Gets the bad files.

Returns
array The bad files.

References $bad_files.

◆ download()

download ( string  $dest)

Downloads new version to destination.

Parameters
string$destThe destination
Exceptions
Exception

References $url, DC_QUERY_TIMEOUT, and getFileURL().

◆ checkDownload()

checkDownload ( string  $zip)

Check downloaded file

Parameters
string$zipThe zip
Returns
bool

References getChecksum().

◆ backup()

backup ( string  $zip_file,
string  $zip_digests,
string  $root,
string  $root_digests,
string  $dest 
)

Backups changed files before an update.

Parameters
string$zip_fileThe zip file
string$zip_digestsThe zip digests
string$rootThe root
string$root_digestsThe root digests
string$destThe destination
Exceptions
Exception
Returns
bool

References getNewFiles().

◆ performUpgrade()

performUpgrade ( string  $zip_file,
string  $zip_digests,
string  $zip_root,
string  $root,
string  $root_digests 
)

Performs an upgrade.

Parameters
string$zip_fileThe zip file
string$zip_digestsThe zip digests
string$zip_rootThe zip root
string$rootThe root
string$root_digestsThe root digests
Exceptions
Exception

References getNewFiles().

◆ getNewFiles()

getNewFiles ( array  $cur_digests,
array  $new_digests 
)
protected

Gets the new files.

Parameters
array$cur_digestsThe current digests
array$new_digestsThe new digests
Returns
array The new files.

Referenced by backup(), and performUpgrade().

◆ readVersion()

readVersion ( string  $str)
protected

Reads a version information from string.

Parameters
string$strThe string

Referenced by getVersionInfo().

◆ md5sum()

md5sum ( string  $root,
string  $digests_file 
)
protected

Return list of changed files

Parameters
string$rootThe root
string$digests_fileThe digests file
Exceptions
Exception
Returns
array

Referenced by checkIntegrity().

◆ parseLine()

parseLine ( $v,
  $k,
  $n 
)
protected

Parse digests file line

Parameters
mixed$vThe value
mixed$kThe key/index
mixed$narray_walk() 3rd arg

◆ md5_check()

static md5_check ( string  $filename,
string  $md5 
)
staticprotected

Check the MD5 of a file

Parameters
string$filenameThe filename
string$md5The MD5 checksum
Returns
bool

Field Documentation

◆ ERR_FILES_CHANGED

const ERR_FILES_CHANGED = 101

Referenced by adminUpdate\process().

◆ ERR_FILES_UNREADABLE

const ERR_FILES_UNREADABLE = 102

Referenced by adminUpdate\process().

◆ ERR_FILES_UNWRITALBE

const ERR_FILES_UNWRITALBE = 103

Referenced by adminUpdate\process().

◆ $url

$url
protected

Referenced by __construct(), and download().

◆ $subject

$subject
protected

Referenced by __construct().

◆ $version

$version
protected

Referenced by __construct(), and check().

◆ $cache_file

$cache_file
protected

◆ $version_info

$version_info
protected
Initial value:
= [
'version' => null,
'href' => null,
'checksum' => null,
'info' => null,
'php' => '7.4',
'warning' => false,
'notify' => true,
]

◆ $cache_ttl

$cache_ttl = '-6 hours'
protected

◆ $forced_files

$forced_files = []
protected

Referenced by getForcedFiles().

◆ $bad_files

$bad_files = []
protected

Referenced by getBadFiles().


The documentation for this class was generated from the following file: