$currName = $_POST['NAME'];
        $type = $_POST['TYPE'];
        if ($type == "QUAL" || $type == "DRAW") {
            echoQD($currName);
        } else {
            if ($type == "PACKAGE") {
                echoPackage($currName);
            } else {
                if ($type == "QDLIST") {
                    echoQDList();
                } else {
                    if ($type == "ADMIN") {
                        echoAdmin();
                    } else {
                        if ($type == "USER") {
                            echoUser();
                        }
                    }
                }
            }
        }
        mysql_close($eldritchSQL);
    }
}
function echoQD($currName)
{
    if ($currName != "") {
        $currRow = mysql_query("SELECT * FROM CGDB_QD WHERE Long_Name = '" . $currName . "'") or trigger_error("PHPError: querying QD name " . mysql_error(), E_USER_ERROR);
        if (mysql_num_rows($currRow) == 1) {
            $currRow = mysql_fetch_array($currRow);
            $QDID = $currRow['ID'];
Exemple #2
0
function getUserGesturesAcc()
{
    global $db;
    $userid = isset($_REQUEST["userid"]) ? (int) $_REQUEST["userid"] : 0;
    // <!-- getUserGesturesAcc(userid="'.$userid.'")-->';
    $exhibitionstate = getExhibitionState();
    if ($userid == 0) {
        echoError(2);
    } else {
        echo '
<result>';
        echoUser($userid);
        echo '
  <overall>';
        $overallco2impact = 0;
        $themegesturesuser = pg_query($db, "SELECT SUM(co2impact) AS co2impact,\n                                               SUM(achievedpercent) AS achievedpercent,\n                                               SUM(treeimpact) AS treeimpact,\n                                               SUM(energyimpact) AS energyimpact,\n                                               SUM(costs) AS costs,\n                                               SUM(savings10years) AS savings10years,\n                                               SUM(co2impactbyswiss) AS co2impactbyswiss,\n                                               SUM(energyimpactbyswiss) AS energyimpactbyswiss\n                                          FROM themegesturesuser WHERE userid = " . $userid);
        while (is_object($theme = pg_fetch_object($themegesturesuser))) {
            echo '
      <co2impact>' . number_format($theme->co2impact, 3, '.', '') . '</co2impact>
      <achievedpercent>' . number_format($theme->achievedpercent, 2, '.', '') . '</achievedpercent>
      <treeimpact>' . number_format($theme->treeimpact, 0, '.', '') . '</treeimpact>
      <energyimpact>' . number_format($theme->energyimpact, 0, '.', '') . '</energyimpact>
      <costs>' . number_format($theme->costs, 0, '.', '') . '</costs>
      <savings10years>' . number_format($theme->savings10years, 0, '.', '') . '</savings10years>
      <co2impactbyswiss>' . number_format($theme->co2impactbyswiss, 0, '.', '') . '</co2impactbyswiss>
      <energyimpactbyswiss>' . number_format($theme->energyimpactbyswiss, 0, '.', '') . '</energyimpactbyswiss>';
            if (is_object($exhibitionstate)) {
                echo '
      <co2comparison>' . number_format($theme->co2impact / $exhibitionstate->co2comparison, 2, '.', '') . '</co2comparison>
      <energycomparison>' . number_format($theme->energyimpact / $exhibitionstate->energycomparison, 2, '.', '') . '</energycomparison>
      <co2comparisonbyswiss>' . number_format($theme->co2impactbyswiss / $exhibitionstate->co2comparison, 2, '.', '') . '</co2comparisonbyswiss>
      <energycomparisonbyswiss>' . number_format($theme->energyimpactbyswiss / $exhibitionstate->energycomparison, 2, '.', '') . '</energycomparisonbyswiss>';
            }
            $overallco2impact = $theme->co2impact;
        }
        echo '
  </overall>
  <themes>';
        $themegesturesuser = pg_query($db, "SELECT t.id, tgu.* FROM theme t\n                                          LEFT JOIN themegesturesuser tgu ON t.id = tgu.themeid AND\n                                                                             tgu.userid = " . $userid . "\n                                         ORDER BY t.id");
        while (is_object($theme = pg_fetch_object($themegesturesuser))) {
            echo '
    <theme>
      <id>' . $theme->id . '</id>
      <co2impact>' . number_format($theme->co2impact, 3, '.', '') . '</co2impact>
      <achievedpercent>' . number_format($theme->achievedpercent, 2, '.', '') . '</achievedpercent>
      <overallpercent>' . number_format($theme->co2impact * 100 / $overallco2impact, 2, '.', '') . '</overallpercent>
      <treeimpact>' . number_format($theme->treeimpact, 0, '.', '') . '</treeimpact>
      <energyimpact>' . number_format($theme->energyimpact, 0, '.', '') . '</energyimpact>
      <costs>' . number_format($theme->costs, 0, '.', '') . '</costs>
      <savings10years>' . number_format($theme->savings10years, 0, '.', '') . '</savings10years>
      <co2impactbyswiss>' . number_format($theme->co2impactbyswiss, 0, '.', '') . '</co2impactbyswiss>
      <energyimpactbyswiss>' . number_format($theme->energyimpactbyswiss, 0, '.', '') . '</energyimpactbyswiss>
    </theme>';
        }
        echo '
  </themes>
</result>';
    }
}