Exemplo n.º 1
0
 public function listAction()
 {
     $db_params = get_db_params_from_config();
     $db_conn = new DBConnection($db_params);
     $db_conn->connect();
     $results = get_users($db_conn);
     return $this->render('TestCMSCMSBundle:Users:list.html.twig', array("results" => $results));
 }
Exemplo n.º 2
0
 public function authenticateAction(Request $req)
 {
     $results = array("token" => "", "success" => "false", "message" => "", "error" => "");
     if (0 === strpos($this->getRequest()->headers->get("Content-Type"), "application/json")) {
         $data = json_decode($this->getRequest()->getContent(), true);
     } else {
         $results["error"] .= "Wrong format received. ";
     }
     $email = filter_var($data["email"], FILTER_SANITIZE_EMAIL);
     $password_dec = filter_var($data["password"], FILTER_SANITIZE_SPECIAL_CHARS);
     $db_params = get_db_params_from_config();
     $db_conn = new DBConnection($db_params);
     $db_conn->connect();
     $res_arr = retrieve_password_fields($conn, $user_name);
     $enc_vals = get_enc_vals();
     $enc_pw = encrypt($_SESSION["salt"], $password_dec, $_SESSION["iv"]);
     // Search database for user with matching encrypted password.
     // ...
     $response = new Response(json_encode($results));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
Exemplo n.º 3
0
    $user_strgs = array();
    foreach ($json_obj->users as $user) {
        $user_strgs[] = sprintf("('%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', \n'%s', '%s')", $user->first_name, $user->last_name, $user->email, $user->password_enc, $user->group_name, $user->active, $user->created_date, $user->updated_date, $user->facebook_id, $user->twitter_id);
    }
    $sql = sprintf($sql, join($user_strgs, ","));
    $res = $db_conn->query($sql);
}
/**
 * Main flow of program.
 */
$web_data_dir = __DIR__ . "/../../../../../web/bundles/testcmscms/data";
$groups_data_fname = "groups_init.json";
$users_data_fname = "users_init.json";
//Try connecting to the database.
$db_params = get_db_params_from_config();
$db_conn = new DBConnection($db_params);
$db_conn->connect();
if (strlen($db_conn->get_error()) > 0) {
    echo "Error: " . $db_conn->get_error();
    exit;
}
//Clear out any existing data.
drop_all_tables($db_conn);
//Create the tables in the database.
$error_msg = create_all_tables($db_conn);
if (strlen($error_msg) > 0) {
    echo $error_msg . "\n";
} else {
    echo "All tables created.\n";
}
//Insert default access_groups into db.