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; } else { // Generate fake cache entry foreach ($mapper as $map => $idx) { $GLOBALS['cache_array']['revision'][$map][0] = $ins_vers[$idx]; } // END - foreach // Return found value $ret = getActualVersion($type); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret[' . $type . ']=' . $ret); } } } // Has it been updated? if ($new === true) { // Write it writeToFile($FQFN, implode("\n", getArrayFromActualVersion())); // ... and call recursive $ret = getActualVersion($type); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret[' . $type . ']=' . $ret); } // END - if } // Return the value //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret[' . $type . ']=' . $ret); return $ret; } // Repares an array we are looking for // The returned Array is needed twice (in getArrayFromActualVersion() and in getActualVersion() 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 $ret = ''; // Searches for "$search-tag:VALUE$" or "$search-tag::VALUE$"(the stylish keywordversion ;-)) in the lates modified file $GLOBALS['revision_res'] += preg_match('@\$' . $search . '(:|::) (.*) \$@U', $fileData, $t); // Make sure only valid and trimmed entries are used if (isset($t[2])) { $ret = trim($t[2]); } // END - if // Return the result return $ret; } // Extracts requested revison info for given file name by reading it's content // and parsing it with extractRevisionInfoFromData(). function extractRevisionInfoFromFile ($FQFN, $search) { // Read the file $fileData = readFromFile($FQFN); // Call the extract function and return the result return extractRevisionInfoFromData($fileData, $search); } // @TODO Please describe this function function getArrayFromActualVersion () { // Init array $GLOBALS['cache_array']['revision'] = array(); // Init variables $next_dir = ''; // Directory to start with search $last_changed = array( 'path_name' => '', 'time' => 0 ); // Init return array $akt_vers = array(); // Init value for counting the founded keywords $GLOBALS['revision_res'] = '0'; // Searches all Files and there date of the last modifikation and puts the newest File in $last_changed. searchDirsRecursive($next_dir, $last_changed, 'Revision'); // Get file $last_file = readFromFile($last_changed['path_name']); // Save the last-changed filename for debugging $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) { // This extracts the requested data $search from file data $last_file if ($search != 'File') { // Skip 'File' because we have set it some lines above $GLOBALS['cache_array']['revision'][$search][0] = extractRevisionInfoFromData($last_file, $search); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'search=' . $search . ',data=' . $GLOBALS['cache_array']['revision'][$search][0]); } // END - if } // END - foreach // at least 3 keyword-Tags are needed for propper values if ($GLOBALS['revision_res'] && $GLOBALS['revision_res'] >= 3 && isset($GLOBALS['cache_array']['revision']['Revision'][0]) && $GLOBALS['cache_array']['revision']['Revision'][0] != '' && isset($GLOBALS['cache_array']['revision']['Date'][0]) && $GLOBALS['cache_array']['revision']['Date'][0] != '' && isset($GLOBALS['cache_array']['revision']['Tag'][0]) && $GLOBALS['cache_array']['revision']['Tag'][0] != '') { // Prepare content witch need special treadment // Prepare timestamp for date preg_match('@(....)-(..)-(..) (..):(..):(..)@', $GLOBALS['cache_array']['revision']['Date'][0], $match_d); $GLOBALS['cache_array']['revision']['Date'][0] = mktime($match_d[4], $match_d[5], $match_d[6], $match_d[2], $match_d[3], $match_d[1]); // 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]); } // END - if } else { // No valid Data from the last modificated file so read the Revision from the Server. Fallback-solution!! Should not be removed I think. $version = sendGetRequest('check-updates3.php'); // Invalid request reply? if (!isset($version[11])) { // Cannot continue here debug_report_bug(__FUNCTION__, __LINE__, 'Invalid response from check-updates3.php, count should be 10+, is ' . count($version)); } // END - if // Prepare content // Only sets not setted or not proper values to the Online-Server-Fallback-Solution if (!isset($GLOBALS['cache_array']['revision']['File'][0]) || $GLOBALS['cache_array']['revision']['File'][0] == '') $GLOBALS['cache_array']['revision']['File'][0] = trim($version[11]); if (!isset($GLOBALS['cache_array']['revision']['Revision'][0]) || $GLOBALS['cache_array']['revision']['Revision'][0] == '') $GLOBALS['cache_array']['revision']['Revision'][0] = trim($version[10]); if (!isset($GLOBALS['cache_array']['revision']['Date'][0]) || $GLOBALS['cache_array']['revision']['Date'][0] == '') $GLOBALS['cache_array']['revision']['Date'][0] = trim($version[9]); if (!isset($GLOBALS['cache_array']['revision']['Tag'][0]) || $GLOBALS['cache_array']['revision']['Tag'][0] == '') $GLOBALS['cache_array']['revision']['Tag'][0] = trim($version[8]); if (!isset($GLOBALS['cache_array']['revision']['Author'][0]) || $GLOBALS['cache_array']['revision']['Author'][0] == '') $GLOBALS['cache_array']['revision']['Author'][0] = 'quix0r'; } // Temporary remove [0] from array $array = $GLOBALS['cache_array']['revision']; foreach ($array as $key => $value) { if ((is_array($value)) && (isset($value[0]))) { unset($array[$key][0]); $array[$key] = $value[0]; } // END - if } // END - if // Return prepared array return $array; } // [EOF] ?>