Пример #1
0
include_once 'ressources/class.templates.inc';
session_start();
include_once 'ressources/class.html.pages.inc';
include_once 'ressources/class.cyrus.inc';
include_once 'ressources/class.main_cf.inc';
include_once 'ressources/charts.php';
include_once 'ressources/class.syslogs.inc';
include_once 'ressources/class.system.network.inc';
include_once 'ressources/class.os.system.inc';
include_once dirname(__FILE__) . "/ressources/class.mysql.squid.builder.php";
if (isset($_GET["popup"])) {
    popup();
    exit;
}
if (isset($_POST["new-password"])) {
    SaveAccount();
    exit;
}
if (isset($_GET["privs"])) {
    privileges();
    exit;
}
page();
function page()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $t = time();
    $html = "\n\t\n\t<table style='width:100%' class=form>\n\t<tr>\n\t\t<td colspan=2 style='font-size:22px'>{myaccount}</td>\n\t</tr>\n\t<tr>\n\t<td width=1% valign='top'><img src='img/user-server-128.png'></td>\n\t<td width=100%' valign='top'><span id='{$t}'></span>\n\t</tr>\n\t</table>\n\t<script>\n\t\tLoadAjax('{$t}','{$page}?popup=yes&t={$t}');\n\t</script>\n";
    echo $tpl->_ENGINE_parse_body($html);
}
Пример #2
0
function GetNewPage()
{
    global $SLOTS, $g_account, $apath;
    $sql = GetSQL();
    $result = $sql->safequery("LOCK TABLES Topics WRITE, TopicVotes READ, Accounts WRITE");
    $result = $sql->safequery('SELECT id,state,time,vote,goods,bads FROM Topics
		LEFT JOIN TopicVotes 
		ON (topicid=id AND TopicVotes.account=' . $g_account->id . ')
		WHERE (state=' . TopicStates::Live . ' 
		OR state=' . TopicStates::Composing . ') 
		LIMIT ' . $SLOTS);
    if ($result->num_rows < $SLOTS) {
        if (time() > $g_account->lastcompose + $GLOBALS['COMPOSE_DELAY']) {
            // chance to make a new
            //if( mt_rand( 0, $SLOTS-1 ) >= $result->num_rows ) {
            // start new composition
            $sql->safequery('INSERT INTO Topics ( account,state,time ) VALUES 
				( ' . $g_account->id . ', ' . TopicStates::Composing . ', ' . time() . ')');
            $result = $sql->safequery('SELECT LAST_INSERT_ID()');
            $row = $result->fetch_row();
            $g_account->page = $row[0];
            $g_account->lastcompose = time();
            $sql->safequery('UPDATE Accounts SET page=' . $g_account->page . ', 
				lastcompose=' . $g_account->lastcompose . ' 
				WHERE id=' . $g_account->id);
            $sql->safequery('UNLOCK TABLES');
            return;
            //}
        }
    }
    $sql->safequery('UNLOCK TABLES');
    $choices = array();
    while ($row = $result->fetch_assoc()) {
        if ($row['state'] == TopicStates::Composing) {
            if (time() >= $row['time'] + $GLOBALS['COMPOSE_TIMEOUT']) {
                // delete timed-out composition.
                // we double-check that it is still in composition mode.
                $sql->safequery('DELETE FROM Topics WHERE id=' . $row['id'] . ' AND state=' . TopicStates::Composing);
                continue;
            }
        } else {
            if ($row['state'] == TopicStates::Live) {
                if (CheckTopicExpired2($row['id'], $row['goods'], $row['bads'], $row['time'])) {
                    continue;
                }
                // skip downvoted topics.
                if (!is_null($row['vote']) && $row['vote'] == 0) {
                    continue;
                }
                $choices[] = $row['id'];
            }
        }
    }
    if (empty($choices)) {
        $g_account->page = 0;
        SaveAccount($g_account, 0);
        return;
    }
    $choice = $choices[mt_rand(0, count($choices) - 1)];
    $g_account->page = $choice;
    SaveAccount($g_account, $g_account->page);
}