Popis
Jedná se o výpis uživatelů z databáze, řazených podle poslední aktivity na webu. Potřeboval jsem to pro jedny klanové stránky. Jedná se spíš o takovou prezenční listinu. Upozorňuji však, že skript není nijak upravován pro varianty X-set uživatelů... Takže nějaké to stránkování by se muselo na žádost dodělat. Pokud je aktivita uživatele starší více než 7 dní, pak vypsaný datum bude zobrazen červeně. Výpis je řazen od nejnovější aktivity po nejstarší.
Kód
<span style="color: #000000">
<br><span style="color: #0000BB"><?php
<br>
<br></span><span style="color: #FF8000">/* --- kontrola jadra --- */
<br></span><span style="color: #007700">if(!</span><span style="color: #0000BB">defined</span><span style="color: #007700">(</span><span style="color: #DD0000">'_core'</span><span style="color: #007700">)) exit;
<br>
<br></span><span style="color: #FF8000">/* --- definice funkce modulu --- */
<br></span><span style="color: #007700">function </span><span style="color: #0000BB">_HCM_df_useractivity</span><span style="color: #007700">()
<br>{
<br></span><span style="color: #0000BB">$output</span><span style="color: #007700">=</span><span style="color: #DD0000">""</span><span style="color: #007700">;
<br></span><span style="color: #0000BB">$query </span><span style="color: #007700">= </span><span style="color: #0000BB">DB</span><span style="color: #007700">::</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT * FROM `"</span><span style="color: #007700">.</span><span style="color: #0000BB">_mysql_prefix</span><span style="color: #007700">.</span><span style="color: #DD0000">"-users` ORDER BY activitytime DESC"</span><span style="color: #007700">);
<br>
<br></span><span style="color: #0000BB">$output</span><span style="color: #007700">.=</span><span style="color: #DD0000">"<table border='0'><tr><th style='width:200px; text-align:left;'>Přezdívka</th><th>Poslední aktivita</th></tr>"</span><span style="color: #007700">;
<br>while(</span><span style="color: #0000BB">$item </span><span style="color: #007700">= </span><span style="color: #0000BB">DB</span><span style="color: #007700">::</span><span style="color: #0000BB">row</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">)) { </span><span style="color: #FF8000">//cyklus
<br>//porovnání data(je starší než týden?)
<br></span><span style="color: #0000BB">$act</span><span style="color: #007700">=((</span><span style="color: #0000BB">time</span><span style="color: #007700">() - </span><span style="color: #0000BB">$item</span><span style="color: #007700">[</span><span style="color: #DD0000">'activitytime'</span><span style="color: #007700">] ></span><span style="color: #0000BB">604800</span><span style="color: #007700">)?</span><span style="color: #DD0000">"<span class='important'>"</span><span style="color: #007700">.</span><span style="color: #0000BB">_formatTime</span><span style="color: #007700">(</span><span style="color: #0000BB">$item</span><span style="color: #007700">[</span><span style="color: #DD0000">'activitytime'</span><span style="color: #007700">]).</span><span style="color: #DD0000">"</span>"</span><span style="color: #007700">:</span><span style="color: #0000BB">_formatTime</span><span style="color: #007700">(</span><span style="color: #0000BB">$item</span><span style="color: #007700">[</span><span style="color: #DD0000">'activitytime'</span><span style="color: #007700">]));
<br></span><span style="color: #FF8000">//výpis
<br></span><span style="color: #0000BB">$output</span><span style="color: #007700">.= </span><span style="color: #DD0000">"<tr><td>"</span><span style="color: #007700">.</span><span style="color: #0000BB">_linkUser</span><span style="color: #007700">(</span><span style="color: #0000BB">$item</span><span style="color: #007700">[</span><span style="color: #DD0000">'id'</span><span style="color: #007700">]).</span><span style="color: #DD0000">"</td><td>"</span><span style="color: #007700">.</span><span style="color: #0000BB">$act</span><span style="color: #007700">.</span><span style="color: #DD0000">"</td></tr>"</span><span style="color: #007700">;
<br>}
<br></span><span style="color: #0000BB">$output</span><span style="color: #007700">.=</span><span style="color: #DD0000">"</table>"</span><span style="color: #007700">;
<br>
<br>return </span><span style="color: #0000BB">$output</span><span style="color: #007700">;
<br>}
<br></span><span style="color: #0000BB">?></span>
</span>
Komentáře
Nebyly přidány žádné komentáře.