X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Frevision-functions.php;h=e61d9788751d69dfd852a1cf351cab7a2d47c615;hp=ef9e0d8a2eefd6aa3a5d2793d0128b196eb5fb82;hb=596c8ab32594401ca84abfbfe35513ddfff31bec;hpb=c3b4eaf29946349ff058691db2dcb615a5379bb2 diff --git a/inc/revision-functions.php b/inc/revision-functions.php index ef9e0d8a2e..e61d978875 100644 --- a/inc/revision-functions.php +++ b/inc/revision-functions.php @@ -16,8 +16,8 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2011 by Mailer Developer Team * - * For more information visit: http://www.mxchange.org * + * Copyright (c) 2009 - 2012 by Mailer Developer Team * + * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -55,16 +55,25 @@ function initRepositoryData () { // Default branch 'Tag' => 8 ); + + // Add Revision, Date, Tag and Author + $GLOBALS['repository_search_for'] = array( + 'File', + 'Revision', + 'Date', + 'Tag', + 'Author' + ); } // "Getter" for revision/version data function getRepositoryData ($type = 'Revision') { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret[' . $type . '] - ENTRY!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret[' . $type . '] - ENTERED!'); // Default is an invalid value to find bugs... :-) $ret = 'INVALID'; // By default nothing is new... ;-) - $new = false; + $new = FALSE; // Is the cache entry there? if (isset($GLOBALS['cache_array']['revision'][$type][0])) { @@ -79,26 +88,26 @@ function getRepositoryData ($type = 'Revision') { $FQFN = sprintf("%s/.revision", getCachePath()); // Check if 'check_revision_data' is setted (switch for manually rewrite the .revision-File) - if ((isGetRequestParameterSet('check_revision_data')) && (getRequestParameter('check_revision_data') == 'yes')) { + if ((isGetRequestElementSet('check_revision_data')) && (getRequestElement('check_revision_data') == 'yes')) { // Forced rebuild of .revision file - $new = true; + $new = TRUE; } else { // Check for revision file if (!isFileReadable($FQFN)) { // Not found, so we need to create it - $new = true; + $new = TRUE; } else { // Revision file found - $ins_vers = explode("\n", readFromFile($FQFN)); + $ins_vers = explode(chr(10), readFromFile($FQFN)); // Get array for mapping information - $mapper = array_flip(getSearchFor()); - //* DEBUG: */ debugOutput('
mapper='.print_r($mapper, true).'
ins_vers=
'.print_r($ins_vers, true).'
'); + $mapper = array_flip($GLOBALS['repository_search_for']); + //* DEBUG: */ debugOutput('
mapper='.print_r($mapper, TRUE).'
ins_vers=
'.print_r($ins_vers, TRUE).'
'); // Is the content valid? if ((!is_array($ins_vers)) || (count($ins_vers) <= 0) || (!isset($ins_vers[$mapper[$type]])) || (trim($ins_vers[$mapper[$type]]) == '') || ($ins_vers[0]) == 'new') { // File needs update! - $new = true; + $new = TRUE; } else { // Generate fake cache entry foreach ($mapper as $map => $idx) { @@ -113,9 +122,9 @@ function getRepositoryData ($type = 'Revision') { } // Has it been updated? - if ($new === true) { + if ($new === TRUE) { // Write it - writeToFile($FQFN, implode("\n", getArrayFromRepositoryData())); + writeToFile($FQFN, implode(chr(10), getArrayFromRepositoryData())); // ... and call recursive $ret = getRepositoryData($type); @@ -124,20 +133,10 @@ function getRepositoryData ($type = 'Revision') { } // Return the value - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret[' . $type . ']=' . $ret); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret[' . $type . ']=' . $ret . ' - EXIT!'); return $ret; } -// Repares an array we are looking for -// The returned Array is needed twice (in getArrayFromRepositoryData() and in getRepositoryData() in the old .revision-fallback) so I puted it in an extra function to not polute the global namespace -function getSearchFor () { - // Add Revision, Date, Tag and Author - $searchFor = array('File', 'Revision', 'Date', 'Tag', 'Author'); - - // Return the created array - return $searchFor; -} - // Extracts requested revision info from given file data function extractRevisionInfoFromData ($fileData, $search) { // Default is to return empty string @@ -196,7 +195,7 @@ function getArrayFromRepositoryData () { $GLOBALS['cache_array']['revision']['File'][0] = $last_changed['path_name']; // This foreach loops the $searchFor-Tags (array('Revision', 'Date', 'Tag', 'Author') --> could easaly extended in the future) - foreach (getSearchFor() as $search) { + foreach ($GLOBALS['repository_search_for'] as $search) { // This extracts the requested data $search from file data $last_file if ($search != 'File') { // Skip 'File' because we have set it some lines above @@ -218,7 +217,7 @@ function getArrayFromRepositoryData () { // Add author to the Tag if the author is set and is not quix0r (lead coder) if ((isset($GLOBALS['cache_array']['revision']['Author'][0])) && ($GLOBALS['cache_array']['revision']['Author'][0] != 'quix0r')) { - $GLOBALS['cache_array']['revision']['Tag'][0] .= '-'.strtoupper($GLOBALS['cache_array']['revision']['Author'][0]); + $GLOBALS['cache_array']['revision']['Tag'][0] .= '-' . strtoupper($GLOBALS['cache_array']['revision']['Author'][0]); } // END - if } else { @@ -228,12 +227,12 @@ function getArrayFromRepositoryData () { // Invalid request reply? if (!isset($version[11])) { // Cannot continue here - debug_report_bug(__FUNCTION__, __LINE__, 'Invalid response from check-updates3.php, count should be at least 11, is ' . count($version)); + reportBug(__FUNCTION__, __LINE__, 'Invalid response from check-updates3.php, count should be at least 11, is ' . count($version)); } // END - if // Prepare content // Only sets not setted or not proper values to the Online-Server-Fallback-Solution - foreach (getSearchFor() as $entry) { + foreach ($GLOBALS['repository_search_for'] as $entry) { // Is it not set or empty? if ((!isset($GLOBALS['cache_array']['revision'][$entry][0])) || (empty($GLOBALS['cache_array']['revision']['File'][0]))) { // Is default data entry nummerical?