showLastModInIndex(); // Sort the repositories by group $config->sortByGroup(); $projects = $config->getRepositories(); if (count($projects) == 1 && $projects[0]->hasReadAccess('/', true)) { header('Location: '.str_replace('&', '', $config->getURL($projects[0], '', 'dir'))); exit; } $cacheFile = $config->getTempDir()."/svnRevisionCache.ser"; $filetime = @filemtime ($cacheFile); if ($filetime && ((time () - $filetime) / 60 / 60 / 24) < 1) { $cache = unserialize(file_get_contents($cacheFile)); $updateCache = false; } else { $cache = array(); $updateCache = true; } $i = 0; $parity = 0; // Alternates between every entry, whether it is a group or project $groupparity = 0; // The first project (and first of any group) resets this to 0 $curgroup = null; $groupcount = 0; // Create listing of all configured projects (includes groups if they are used). foreach ($projects as $project) { if (!$project->hasReadAccess('/', true)) continue; // If this is the first project in a group, add an entry for the group. if ($curgroup != $project->group) { $groupcount++; $groupparity = 0; $listing[$i]['notfirstgroup'] = !empty($curgroup); $curgroup = $project->group; $listing[$i]['groupname'] = $curgroup; // Applies until next group is set. $listing[$i]['groupid'] = strtr(base64_encode('grp'.$curgroup), array('+' => '-', '/' => '_', '=' => '')); $listing[$i]['projectlink'] = null; // Because template.php won't unset this $i++; // Causes the subsequent lines to store data in the next array slot. $listing[$i]['groupid'] = null; // Because template.php won't unset this } $listing[$i]['clientrooturl'] = $project->clientRootURL; // Populate variables for latest modification to the current repository if ($config->showLastModInIndex()) { if (!empty($cache[$project->name])) { $listing[$i]['revision'] = $cache[$project->name]['revision']; $listing[$i]['date'] = $cache[$project->name]['date']; $listing[$i]['age'] = $cache[$project->name]['age']; $listing[$i]['author'] = $cache[$project->name]['author']; } else { $svnrep = new SVNRepository($project); $log = $svnrep->getLog('/', '', '', true, 1); if (isset($log->entries[0])) { $head = $log->entries[0]; $listing[$i]['revision'] = $head->rev; $listing[$i]['date'] = $head->date; $listing[$i]['age'] = datetimeFormatDuration(time() - strtotime($head->date)); $listing[$i]['author'] = $head->author; } else { $listing[$i]['revision'] = 0; $listing[$i]['date'] = ''; $listing[$i]['age'] = ''; $listing[$i]['author'] = ''; } $cache[$project->name]['revision'] = $listing[$i]['revision']; $cache[$project->name]['date'] = $listing[$i]['date']; $cache[$project->name]['age'] = $listing[$i]['age']; $cache[$project->name]['author'] = $listing[$i]['author']; } } // Create project (repository) listing $url = str_replace('&', '', $config->getURL($project, '', 'dir')); $name = ($config->flatIndex) ? $project->getDisplayName() : $project->name; $listing[$i]['projectlink'] = ''.escape($name).''; $listing[$i]['rowparity'] = $parity % 2; $parity++; $listing[$i]['groupparity'] = $groupparity % 2; $groupparity++; $listing[$i]['groupname'] = ($curgroup != null) ? $curgroup : ''; $i++; } if (empty($listing) && !empty($projects)) { $vars['error'] = $lang['NOACCESS']; checkSendingAuthHeader(); } if ($updateCache && ($fp = @fopen ($cacheFile, "w"))) { fwrite ($fp, serialize($cache)); } $vars['flatview'] = $config->flatIndex; $vars['treeview'] = !$config->flatIndex; $vars['opentree'] = $config->openTree; $vars['groupcount'] = $groupcount; // Indicates whether any groups were present. renderTemplate('index');