News:

CPG Release 1.6.29
During HTML5 upload, keep pseudo blank code 200 messages from triggering error condition
added Russian language
correct failure to use theme menu icons in album manager
minor vulnerabilities mitigation

Main Menu

MOD: Upload Activity By Time

Started by pslawinski, November 20, 2005, 08:16:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pslawinski

I got bored, so I wrote up a little script that will make a graph showing upload activity by time on the profile page for any  user.


profile.php

Find:

        pagefooter();
        ob_end_flush();
        break;
}


Replace with:
Note: Replace all references to images/siteLayout/Contentpanel_Sidebar_11.gif with your own image

//Upload Activity By Time
starttable(705, "Upload Activity By Time", 1);
$query = "SELECT ctime as uploadTime FROM {$CONFIG['TABLE_PICTURES']} as p WHERE p.owner_id = '$uid'";
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result);
mysql_free_result($result);
$uploadTimes = array();
$total = 0;
foreach($rowset as $row)
{
switch(strftime("%H",$row[0]))
{
case '00':
$index = 0;
break;
case '01':
$index = 1;
break;
case '02':
$index = 2;
break;
case '03':
$index = 3;
break;
case '04':
$index = 4;
break;
case '05':
$index = 5;
break;
case '06':
$index = 6;
break;
case '07':
$index = 7;
break;
case '08':
$index = 8;
break;
case '09':
$index = 9;
break;
default:
$index = strftime("%H",$row[0]);
}
$uploadTimes[$index] = @$uploadTimes[$index] + 1;
$total++;
}

ksort($uploadTimes, SORT_NUMERIC);

print('<tr><td align="center" colspan="26"><b>Time of Day (GMT'.$CONFIG['time_offset'].')</b></td></tr>');
print('<tr><td align="center" colspan="26" height="2"></td></tr>');
print('<tr><td align="center" colspan="26" height="2" bgcolor="#000000"></td></tr>');
print('<tr><td align="center" colspan="26" height="1"></td></tr>');
print('<tr><td height="100" width="1" valign="bottom"><img src="images/siteLayout/Contentpanel_Sidebar_11.gif" width="1" height="200" /></td>');
for($i = '0'; $i <= '23'; $i++)
{
if(isset($uploadTimes[$i]))
{
print('<td height="100" width="4%" valign="bottom" align="center" style="font-size: 80%">'.round($uploadTimes[$i]/$total*'100',0).'%<br /><img src="images/siteLayout/Contentpanel_Sidebar_05.gif" border="1" alt="" width="15" height="'.round($uploadTimes[$i]/$total*'200',0).'" /></td>');
}
else
{
print('<td height="100" width="4%"></td>');
}
}
print('<td height="100" width="1" valign="bottom"><img src="images/siteLayout/Contentpanel_Sidebar_11.gif" width="1" height="200" /></td></tr>');
print('<tr><td align="center" colspan="26" height="1"></td></tr>');
print('<tr><td align="center" colspan="26" height="2" bgcolor="#000000"></td></tr>');
print('<tr><td align="center" colspan="26" height="1"></td></tr>');
print('<tr><td></td>');
for($i = '0'; $i <= '23'; $i++)
{
#if(isset($uploadTimes[$i]))
#{
# print('<td width="15">'.$i.' ('.round($uploadTimes[$i]/$total*'200',0).'%)</td>');
#}
#else
#{
print('<td width="4%" align="center">'.$i.'</td>');
#}
}
print('<td></td></tr>');

endtable();

        pagefooter();
        ob_end_flush();
        break;
}


I've attached a grab from the site:

Joachim Müller

Thanks for your contrib. What coppermine version did you write/test this mod for?

pslawinski

I wrote and tested this with 1.4.x.  I believe it should work with previous versions if cpg_db_query() and cpg_db_fetch_rowset() are changed to db_query() and db_fetch_rowset() respectively.  Perhaps someone else can test this?  I no longer have a working version of 1.3.x on my server.