cvs: php-gcov-web(SOC06) /www index.php site.api.php
| From: | Nuno Lopes | Date: | Thu, 07 Sep 2006 17:04:36 +0000 |
| Subject: | cvs: php-gcov-web(SOC06) /www index.php site.api.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-32377@lists.php.net to get a copy of this message | ||
nlopess Thu Sep 7 17:04:36 2006 UTC
Modified files: (Branch: SOC06)
/php-gcov-web/www index.php site.api.php
Log:
move the time_diff() function to the www code and use it on the front page
http://cvs.php.net/viewvc.cgi/php-gcov-web/www/index.php?r1=1.1.2.6&r2=1.1.2.7&diff_format=u
Index: php-gcov-web/www/index.php
diff -u php-gcov-web/www/index.php:1.1.2.6 php-gcov-web/www/index.php:1.1.2.7
--- php-gcov-web/www/index.php:1.1.2.6 Sat Sep 2 22:35:57 2006
+++ php-gcov-web/www/index.php Thu Sep 7 17:04:36 2006
@@ -37,7 +37,7 @@
<th>TAG</th>
<th>Last Attempted<br />Build Date</th>
<th>Last Successful<br />Build Date</th>
-<th>Last Build <br /> Time (seconds)</th>
+<th>Last Build <br /> Time</th>
</tr>
<?php
@@ -50,7 +50,7 @@
echo "<th align='left'><a
href='viewer.php?version=$version_name'>$version_name</a></th>";
echo
'<td>'.$version_last_attempted_build_date.'</td>'."\n";
echo
'<td>'.$version_last_successful_build_date.'</td>'."\n";
- echo '<td>'.$version_last_build_time.'</td>'."\n";
+ echo
'<td>'.time_diff($version_last_build_time).'</td>'."\n";
// End additions
echo "</tr>\n";
http://cvs.php.net/viewvc.cgi/php-gcov-web/www/site.api.php?r1=1.1.2.7&r2=1.1.2.8&diff_format=u
Index: php-gcov-web/www/site.api.php
diff -u php-gcov-web/www/site.api.php:1.1.2.7 php-gcov-web/www/site.api.php:1.1.2.8
--- php-gcov-web/www/site.api.php:1.1.2.7 Sat Sep 2 23:05:54 2006
+++ php-gcov-web/www/site.api.php Thu Sep 7 17:04:36 2006
@@ -14,8 +14,7 @@
if(!$mysqlconn)
{
- echo 'Unable to access the database at this time. Please try again in a few minutes';
- exit;
+ die('Unable to access the database at this time. Please try again in a few minutes');
}
@@ -25,29 +24,38 @@
{
$appvars['site']['mytag'] = null;
-
- // Start loading version tags
-
- // todo: if this fails then the tags can not be loaded
- $content = file_get_contents($appvars['site']['tagsfile']);
+ $appvars['page']['headtitle'] = 'PHP: Test and Code Coverage
Analysis';
- $content = trim($content);
- $elements = explode("\n", $content);
- $numelements = count($elements);
+ // load version tags
+ $elements = (array)@file($appvars['site']['tagsfile']);
- // Recall: the first two elements are only used by the cron scripts
- for($i = 2; $i < $numelements; $i++)
+ foreach ($elements as $ver)
{
- $appvars['site']['tags'][$elements[$i]] = trim($elements[$i]);
- }
- // End version tag loading
-
- // Creates instances such as the database connection, if needed
+ $ver = trim($ver);
+ $appvars['site']['tags'][$ver] = trim($ver);
+ }
+}
- $appvars['page']['headtitle'] = 'PHP: Test and Code Coverage
Analysis';
+
+function time_diff($time, $abs=false)
+{
+ if ($abs) {
+ date_default_timezone_set('UTC');
+ $time -= time();
+ }
+
+ if ($time < 60) {
+ return "$time seconds";
+ }
+ elseif ($time < 3600) {
+ return intval($time/60) . ' minutes';
+ } else {
+ return intval($time/3600) . ' hours';
+ }
}
+
// Application Header Function
function api_showheader($appvars=array())
{