International forum: Programming/webmasters - commenting your codes
Share this topic
13 Feb 2014 13:09

All programs should be commented in such a manner as to easily describe (in English) the purpose of the code and any algorithms used to accomplish the purpose. A user should be able to utilize function) without ever having to look at the code, simply by reading the comments

18 Jun 2014 18:42

Ok,this code is online php code how to add best online members ?


<?php

$title = $tlapa.': online';
$sakt = microtime(1);
$id = idsid($sid);
$info1 = infoid($id);

if ($info1['on_skaits']>=1)
{
$osl = $info1['on_skaits'];
}

////////////////////////////////////////////////////online teksts

if (isset($_POST['teksts']) && $sid!='')
{
online_teksts($sid, $_POST['teksts']);
}

/////////////////////////////////////////////////////////////////

//iegūstam datus par online lietotājiem

if (intval($_GET['lapa'])<=0)
{
$lapa = 0;
$nr = 1;
}
else
{
$lapa = $osl*(intval($_GET['lapa'])-1);
$nr = intval($_GET['lapa']);
}

$vieta = $lapa+1;
$starpiba = time()-$oses;
$cik_online = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM online WHERE laiks>'".$starpiba."'"));
$online = mysql_query("SELECT * FROM online WHERE laiks>'".$starpiba."' ORDER BY laiks DESC LIMIT $lapa, $osl");
$lapu_skaits = ceil($cik_online[0]/$osl);

require_once('include/augsa.php');

echo '<div class="sani" style="text-align: center">';
echo ' <a href="./?kas=jaunie&sid='.$sid.'">Newest people </a> -- <font class="ramis">Online </font> ';
echo ' --<a href="./?kas=administracija&sid='.$sid.'">Admins </a><br/>';
echo '</div>';
if ($cik_online[0]>0)
{
if ($sid!='')
{
echo '<div class="vidus" style="text-align: left">';
echo '<form action="./?kas=online&sid='.$sid.'" method="post">';
echo '<input type="text" name="teksts" value="'.online_teksts($sid, "").'" maxlength="60" size="8"/>';
echo '<input type="submit" value="Say"/></form>';
echo '</div>';

}

while ($on = mysql_fetch_array($online, MYSQL_ASSOC))
{
echo '<div class="vidus" style="text-align: left">';

if ($on['id']>0)
{
$niks = infoid($on['id']);
echo '<small><b>'.$vieta.')</b> <a href="./?kas=profils&sid='.$sid.'&kam='.$on['id'].'">'.$niks['niks'].'</a> - '.$on['kur'].'</small>';
}
else
{
echo '<small><b>'.$vieta.')</b> '.$on['browseris'].' ('.$on['ip'].') - '.$on['kur'].'</small>';
}

if (!empty($on['teksts']))
{
echo '<br/><small><u>Say</u>: '.skatit($on['teksts'], $info1['smiles']).'</small>';
}

echo '</div>';

$vieta++;
}

if ($lapu_skaits>1)
{
echo '<div class="vidus" style="text-align: center">';

if ($lapa>0)
{
echo '<a href="./?kas=online&sid='.$sid.'&lapa='.($nr-1).'">Back</a> ';
}

echo '<b>'.$nr.'</b>/<b>'.$lapu_skaits.'</b>';

if ($nr<$lapu_skaits)
{
echo ' <a href="./?kas=online&sid='.$sid.'&lapa='.($nr+1).'">Next</a>';
}

if ($lapu_skaits>2)
{

echo '<form action="./" method="get">';
echo 'Lapa <input name="lapa" format="*N" size="3"/>';
echo '<input name="kas" type="hidden" value="online"/>';
echo '<input name="sid" type="hidden" value="'.$sid.'"/>';
echo ' <input type="submit" value="Go"/>';
echo "</form>";
}

echo '</div>';
}
}
else
{
echo '<div class="vidus" style="text-align: left">';
echo 'All is offline!';
echo '</div>';
}

echo '<div class="vidus" style="text-align: left">';

$back = getenv('HTTP_REFERER');

if (!empty($atpakal))
{
echo '• <a href="'.$atpakal.'">Back</a><br/>';
}

echo '• <a href="./?kas=&sid='.$sid.'">Home</a><br/>';
echo '</div>';

?>

20 Aug 2014 08:57

.