Beispiel #1
0
     '" .$_SERVER['REMOTE_ADDR'] . "', " . count($persons) . ")");
  $ssid = mysql_insert_id();
}

$t = new Smarty();

$t->assign('query', $query);
$t->assign('ssid', $ssid);

$p = array();
for ($i = 0; $i < count($persons); $i++) {
  $person = array(
    'id' => $persons[$i]->id,
    'tiny_img_url' => $persons[$i]->getTinyImgUrl(),
    'display_name' => $persons[$i]->displayName,
    'party_name' => getPartyNameForId($persons[$i]->getFact('party')),
    'history_snippet' => $persons[$i]->getHistorySnippet()
  );
  $p[] = $person;
}

$t->assign('persons', $p);

if (trim($_GET['d']) == 'true') {
  $declarations = searchDeclarations($query);
  $t->assign('declarations', $declarations);
  $t->assign('searched_declarations', true);
} else {
  $t->assign('searched_declarations', false);
}
/**
 * Tests whether there are values in the URL for the party percentage or
 * votes. If that is true, it simulates the elections system and then
 * it prints the people that would get elected.
 * @return {boolean} True if an election was simulated, false otherwise.
 *     This will be used to decide whether we will still display all the
 *     candidates or just the elected ones.
 */
function maybeDisplaySimulationResults()
{
    global $_GET;
    global $VOT_PRESENCE;
    $v = getSimulationSystemValuesFromGet();
    if ($v != null) {
        $seats = simulateDHondtSystem($v);
        echo "Cu aceste procente și o prezență generală la vot " . "de {$VOT_PRESENCE}%, aceștia ar fi europarlamentarii:";
        echo "<table cellspacing=5><tr bgcolor=\"#EEEEEE\"><td></td>" . "<td>Nume</td>";
        echo "<td></td><td></td><td></td><td></td>" . "<td>Partid</td>";
        $count = 1;
        foreach ($seats as $p => $v) {
            $idparty = substr($p, 1);
            switch ($idparty) {
                case "a":
                    $idparty = "10 AND e.idperson=3336 ";
                    break;
                case "b":
                    $idparty = "10 AND e.idperson=3335 ";
                    break;
            }
            $s = mysql_query("SELECT e.name, e.idperson, e.occupation, e.birthday, " . "p.name as pname, h4.what as wh4, " . "h1.what as wh1, h2.what as wh2, h3.what as wh3 " . "FROM euro_2009_candidates AS e " . "LEFT JOIN parties AS p ON p.id = e.idparty " . "LEFT JOIN people_history AS h1 " . "ON e.idperson = h1.idperson AND h1.what='catavencu/2008' " . "LEFT JOIN people_history AS h2 " . "ON e.idperson = h2.idperson AND h2.what='results/2008' " . "LEFT JOIN people_history AS h3 " . "ON e.idperson = h3.idperson AND h3.what='euro_parliament/2007' " . "LEFT JOIN people_history AS h4 " . "ON e.idperson = h4.idperson AND h4.what='qvorum/2009' " . "WHERE idparty={$idparty} " . "ORDER BY position ASC " . "LIMIT 0, {$seats[$p]}");
            if ($idparty != "10 AND e.idperson=3336 " && $idparty != "10 AND e.idperson=3335 ") {
                echo "<tr bgcolor=#FAFAFA>";
                echo "<td colspan=7 align=center>" . getPartyNameForId($idparty) . " - {$seats[$p]} locuri</td>";
            }
            while ($r = mysql_fetch_array($s)) {
                echo "<tr>";
                echo "<td align=right>" . $count++ . "</td>";
                $name = moveFirstNameLast(ucwords(strtolower_ro($r['name'])));
                echo "<td><a href=\"?name=" . urlencode($name) . "&cid=9&id={$r['idperson']}\">{$name}</a>";
                $age = round((time() * 1000 - $r['birthday']) / (1000 * 60 * 60 * 24 * 365));
                echo ", {$age} ani";
                $idperson = $r['idperson'];
                echo "</td>";
                echo "<td align=right>" . getIconHtml($r['wh1'], $idperson) . "</td>";
                echo "<td align=right>" . getIconHtml($r['wh2'], $idperson) . "</td>";
                echo "<td align=right>" . getIconHtml($r['wh3'], $idperson) . "</td>";
                echo "<td align=right>" . getIconHtml($r['wh4'], $idperson) . "</td>";
                //echo "<td><span class=\"small gray\">{$r['occupation']}</span></td>";
                echo "<td>{$r['pname']}</td>";
            }
        }
        echo "</table>";
        return true;
    }
    return false;
}
Beispiel #3
0
// And now here I should put some content, like something about the elections,
// some stats, some news, something like that.
if ($query && $restrict != "cs") {
    $persons = search($query);
}
if ($query != "") {
    // add it to the database
    mysql_query("INSERT INTO log_searches(query, time, ip, num_results)\n     VALUES('" . mysql_real_escape_string($query) . "', " . time() . ",\n     '" . $_SERVER['REMOTE_ADDR'] . "', " . count($persons) . ")");
    $ssid = mysql_insert_id();
}
$t = new Smarty();
$t->assign('query', $query);
$t->assign('ssid', $ssid);
$p = array();
for ($i = 0; $i < count($persons); $i++) {
    $person = array('id' => $persons[$i]->id, 'tiny_img_url' => $persons[$i]->getTinyImgUrl(), 'display_name' => $persons[$i]->displayName, 'party_name' => getPartyNameForId($persons[$i]->getFact('party')), 'history_snippet' => $persons[$i]->getHistorySnippet());
    $p[] = $person;
}
$show_people = count($p) > 0;
$t->assign('persons', $p);
if (trim($_GET['d']) == 'true') {
    $declarations = searchDeclarations($query);
    $t->assign('declarations', $declarations);
    $t->assign('searched_declarations', true);
    $show_people = $show_people || count($declarations) > 0;
} else {
    $t->assign('searched_declarations', false);
}
$colleges = getCollegeSearch($query);
$t->assign('colleges', $colleges);
$show_people = $show_people || count($colleges) == 0;