X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=b326dab09832063588ebb76fd1a328c91088a55e;hp=6a87f258cce888a8cdc0a1836a5d528ac22922d8;hb=62b16291efe168636f5eda2c8644f6770382fb1e;hpb=0626c932e7b895a22f390523f4e6248ca77cfb98 diff --git a/inc/functions.php b/inc/functions.php index 6a87f258cc..b326dab098 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -3013,6 +3013,23 @@ function READ_FILE ($FQFN, $sqlPrepare = false) { return $content; } +// Writes content to a file +function WRITE_FILE ($FQFN, $content) { + // Is the function there? + if (function_exists('file_put_contents')) { + // Write it directly + file_put_contents($FQFN, $content); + } else { + // Write it with fopen + $fp = fopen($FQFN, 'w') or mxchange_die("Cannot write file ".basename($FQFN)."!"); + fwrite($fp, $content); + fclose($fp); + + // Set CHMOD rights + chmod($FQFN, 0644); + } +} + // Generates an error code from given account status function GEN_ERROR_CODE_FROM_ACCOUNT_STATUS ($status) { // Default error code if unknown account status @@ -3043,6 +3060,48 @@ function clearOutputBuffer () { } // END - if } +// "Getter" for revision/version data +function getActualVersion ($type = 0) { + // By default nothing is new... ;-) + $new = false; + + // FQFN of revision file + $FQFN = sprintf("%sinc/cache/.revision", PATH); + + // Check for revision file + if (!FILE_READABLE($FQFN)) { + // Not found, so we need to create it + $new = true; + } else { + // Revision file found + $ins_vers = explode("\n", READ_FILE($FQFN)); + + // Is the content valid? + if ((!is_array($ins_vers)) || (count($ins_vers) <= 0) || (!isset($ins_vers[$type])) || ($ins_vers[0]) == "new") { + // File needs update! + $new = true; + } else { + // Revision-File has valid Data and isn't 'new' so return the Rev-Number + return trim($ins_vers[$type]); + } + } + + if ($new) { + // no Revision-File or has no valid Data so read the Revision from the Server. + $version = GET_URL("check-updates3.php"); + + // Prepare content + $akt_vers[] = trim($version[10]); + $akt_vers[] = trim($version[9]); + $akt_vers[] = trim($version[8]); + + // Write file + WRITE_FILE($FQFN, implode("\n", $akt_vers)); + + // Return requested content + return trim($akt_vers[$type]); + } +} ////////////////////////////////////////////////// // AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS // //////////////////////////////////////////////////