Example #1
0
function login($email, $password)
{
    // check username and password with db
    // if yes, return true
    // else throw exception
    // connect to db
    $dbInfo = initialize_db_info();
    $dbLink = db_connect($dbInfo);
    db_select($dbLink, $dbInfo);
    $sql = generateUserVerificationSql($email, $password);
    // check if username is unique
    $result = mysql_query($sql, $dbLink);
    if (!$result || mysql_num_rows($result) == 0) {
        // The username and password did not match.
        // Check to see if the user exists.
        if (findUsername($email)) {
        } else {
        }
    }
    if (mysql_num_rows($result) > 0) {
        $row = mysql_fetch_assoc($result);
        $currentUser = new user_info();
        $currentUser->setId($row['id']);
        $currentUser->setFirstName($row['first_name']);
        $currentUser->setLastName($row['last_name']);
        $currentUser->setEmail($row['email']);
        $currentUser->setHunterId($row['hunter_id']);
        $currentUser->setLoggedIn(true);
        $_SESSION['current_user'] = $currentUser;
        $_SESSION['roles'] = getRoles($currentUser);
        return $currentUser;
    } else {
        throw new Exception('no user found 2');
    }
}
Example #2
0
    print $title;
    ?>
</td>
              <td><?php 
    print $archive;
    ?>
</td>
              <td><?php 
    print $type;
    ?>
</td>
              <?php 
    if (isSuper()) {
        ?>
                <td><?php 
        print findUsername($userID);
        ?>
</td>
              <?php 
    }
    ?>
              <td>
                <a href="view?id=<?php 
    print $id;
    ?>
" class="btn btn-sm btn-primary">View</a>
                <a href="edit?id=<?php 
    print $id;
    ?>
" class="btn btn-sm btn-success">Edit</a>
                <a href="rdf?id=<?php 
Example #3
0
/**
 * Renders a data table on the comments page.
 *
 * @param {String} $value: The value of the selected item.
 */
function renderTable($value)
{
    global $mysqli;
    $statement;
    if ($value == "genre") {
        $statement = $mysqli->prepare("SELECT genre_required_available, genre_controlled_available, suggested_terms_genre, user_id FROM comments");
    } else {
        if ($value == "type_available") {
            $statement = $mysqli->prepare("SELECT type_available, suggested_terms_type, user_id FROM comments");
        } else {
            if ($value == "role_available") {
                $statement = $mysqli->prepare("SELECT role_available, suggested_terms_role, user_id FROM comments");
            } else {
                $statement = $mysqli->prepare("SELECT {$value}, user_id FROM comments");
            }
        }
    }
    $statement->execute();
    $statement->store_result();
    if ($value == "genre") {
        $statement->bind_result($required, $controlled, $suggested, $userID);
    } else {
        if ($value == "type_available" || $value == "role_available") {
            $statement->bind_result($available, $suggested, $userID);
        } else {
            $statement->bind_result($commentColumn, $userID);
        }
    }
    ?>
  <table class="table table-striped table-hover dt">
    <thead>
      <tr>
        <th>Username</th>

        <?php 
    if ($value == "genre") {
        ?>
          <th>Required/Optional</th>
          <th>Controlled/Free-Form</th>
          <th>Suggested Terms</th>
        <?php 
    } elseif ($value == "type_available" || $value == "role_available") {
        ?>
          <th>Available</th>
          <th>Suggested Terms</th>
        <?php 
    } else {
        ?>
          <th>Decision</th>
        <?php 
    }
    ?>
      </tr>
    </thead>
    <tbody>
      <?php 
    while ($statement->fetch()) {
        ?>
        <tr>
          <td><?php 
        print findUsername($userID);
        ?>
</td>

          <?php 
        if ($value == "genre") {
            ?>
            <td><?php 
            print $required == "true" ? "Required" : $required == "false" ? "Optional" : "<em>No data given</em>";
            ?>
</td>
            <td><?php 
            print $controlled == "true" ? "Controlled" : $required == "false" ? "Free-form" : "<em>No data given</em>";
            ?>
</td>
            <td><?php 
            print renderTableCell($suggested);
            ?>
</td>
          <?php 
        } elseif ($value == "type_available" || $value == "role_available") {
            ?>
            <td><?php 
            print renderTableCell($available);
            ?>
</td>
            <td><?php 
            print renderTableCell($suggested);
            ?>
</td>
          <?php 
        } else {
            ?>
            <td><?php 
            print renderTableCell($commentColumn);
            ?>
</td>
          <?php 
        }
        ?>
        </tr>
      <?php 
    }
    ?>
    </tbody>
  </table>
  <?php 
}