$db = new ConnectMySql(); if (isset($_POST["get"])) { $action = $_POST["get"]; } else { $aValues = json_decode(file_get_contents("php://input"), true); $action = $aValues["get"]; $action = $aValues["random"]; } $aData = array(); $aData["records"] = array(); $aData["message_list"] = array(); $sSelectTrivia = "SELECT question.qes_question, first_answer.ans_answer AS 'answer_1', first_answer.ans_correct AS 'answer_1_correct', second_answer.ans_answer AS 'answer_2', second_answer.ans_correct AS 'answer_2_correct', question.qes_active " . " FROM wds_answers_question trivia " . " INNER JOIN wds_answer first_answer ON (trivia.anqe_first_answer_id = first_answer.ans_id) " . " INNER JOIN wds_answer second_answer ON (trivia.anqe_second_answerd_id = second_answer.ans_id) " . " INNER JOIN wds_questions question ON (trivia.anqe_question_id = question.qes_id) " . " WHERE trivia.anqe_active = TRUE"; if (is_null($action)) { $aValues = $_POST["trivia"]; $aValues["question"] = str_replace("\"", "\"", str_replace("'", "\\'", htmlentities($aValues["question"]))); $cmd = $db->command("select * from wds_questions q where q.qes_question = '{$aValues["question"]}'"); if ($db->NumRowsAffected() > 0) { array_push($aData["message_list"], "Question <div class='alert alert-warning'>{$aValues["question"]}</div> is already on our data base, please send another one."); } else { $aValues["first_answer_correct"] = isset($aValues["first_answer_correct"]) ? 1 : 0; $aValues["second_answer_correct"] = isset($aValues["second_answer_correct"]) ? 1 : 0; $aValues["second_answer"] = str_replace("\"", "\"", str_replace("'", "\\'", htmlentities($aValues["second_answer"]))); $aValues["second_answer"] = str_replace("\"", "\"", str_replace("'", "\\'", htmlentities($aValues["second_answer"]))); $sInsertFirstAnswer = "INSERT INTO wds_answer (ans_answer, ans_correct, ans_created_by, ans_updated_by, ans_created_at, ans_updated_at, ans_active) VALUES ('{$aValues["first_answer"]}', {$aValues["first_answer_correct"]}, 1, 1, now(), now(), 1)"; $cmdInsertFirstAnswers = $db->command($sInsertFirstAnswer, true); $iFirstAnswerID = $db->GetInsertedID(); $sInsertSecondAnswer = "INSERT INTO wds_answer (ans_answer, ans_correct, ans_created_by, ans_updated_by, ans_created_at, ans_updated_at, ans_active) VALUES ('{$aValues["second_answer"]}', {$aValues["second_answer_correct"]}, 1, 1, now(), now(), 1)"; $cmdInsertSecondAnswers = $db->command($sInsertSecondAnswer, true); $iSecondAnswerID = $db->GetInsertedID(); $sInsertQuestion = "INSERT INTO wds_questions (qes_question, qes_created_by, qes_updated_by, qes_created_at, qes_updated_at, qes_active) VALUES ('{$aValues["question"]}', 1, 1, now(), now(), 1)"; $cmdInsert = $db->command($sInsertQuestion, true);
<?php error_reporting(E_STRICT); include_once "cls_connection.php"; $db = new ConnectMySql(); $aValues = $_POST["user"]; $aData = array(); $aData["message_list"] = array(); if ($aValues["userid"] !== "") { $cmd = $db->command("select * from wds_users u where u.user_username = '******'"); if ($db->NumRowsAffected() > 0) { array_push($aData["message_list"], "Username {$aValues["userid"]} is already taken, please select another."); } else { $aValues["password"] = md5("WhatdidyousayUser " . $aValues["password"]); $cmdInsert = $db->command("INSERT INTO wds_users (user_full_name, user_username, user_password, user_is_online, user_created_at, user_updated_at, user_active) VALUES ('{$aValues["name"]}', '{$aValues["userid"]}', '{$aValues["password"]}', 0, now(), now(), 1)"); if ($db->NumRowsAffected() > 0) { $aData["success"] = "User {$aValues["userid"]} created successfully"; } else { array_push($aData["message_list"], "User was unable to be inserted. This is the error: " . $db->GetError()); } } } else { array_push($aData["message_list"], "Please fill form so we can sign you up."); } echo json_encode($aData);
<?php error_reporting(E_STRICT); include_once "ConnectMySql.class.php"; include_once "Carrito.class.php"; $db = new ConnectMySql(); $oCarrito = new Carrito(); $aValues["productos"] = $oCarrito->get_content(); $aValuesUser = $_POST["user"]; $aData = array(); $aData["message_list"] = array(); if ($aValues["productos"] !== "") { if (is_array($aValues["productos"])) { $aValues["productos"] = json_encode($aValues["productos"]); } $cmdInsert = $db->command("INSERT INTO flo_pagos (\n\t\t\tpag_productos,\n\t\t\tpag_usuario_nombre,\n\t\t\tpag_usuario_apellido,\n\t\t\tpag_usuario_telefono,\n\t\t\tpag_usuario_email,\n\t\t\tpag_usuario_localidad,\n\t\t\tpag_usuario_numero_tarjeta,\n\t\t\tpag_usuario_direccion,\n\t\t\tpag_updated_at,\n\t\t\tpag_active)\n\t\tVALUES (\n\t\t\t'{$aValues["productos"]}',\n\t\t\t'{$aValuesUser["nombre"]}',\n\t\t\t'{$aValuesUser["apellido"]}',\n\t\t\t'{$aValuesUser["telefono"]}',\n\t\t\t'{$aValuesUser["email"]}',\n\t\t\t'{$aValuesUser["localidad"]}',\n\t\t\t'{$aValuesUser["numero_tarjeta"]}',\n\t\t\t'{$aValuesUser["direccion"]}',\n\t\t\tnow(),\n\t\t\t1)"); if ($db->NumRowsAffected() > 0) { $aData["success"] = "Pago creado exitosamente."; $aData["id"] = $db->GetLastID(); } else { array_push($aData["message_list"], "Pago no fue guardado. Este es el error: " . $db->GetError()); } } else { array_push($aData["message_list"], "Por favor hacer una compra primero."); } echo json_encode($aData);
<?php error_reporting(E_STRICT); include_once "cls_connection.php"; $db = new ConnectMySql(); $aValues = json_decode(file_get_contents("php://input"), true); $aData = array(); $aData["records"] = array(); $aData["message_list"] = array(); if (isset($aValues)) { $sTriviaText = $aValues["text"]; $iCorrect = (bool) $aValues["correct"]; $aUser = $aValues["user"]; if ($iCorrect) { $aUser["user_lifetime_score"] = $aUser["user_lifetime_score"] + 1; $aUser["user_game_score"] = $aUser["user_game_score"] + 1; $sUpdateUserProfile = "UPDATE wds_users SET user_lifetime_score = {$aUser["user_lifetime_score"]}, user_game_score = {$aUser["user_game_score"]} " . " WHERE user_active = TRUE AND user_id = {$aUser["user_id"]}"; $cmd = $db->command($sUpdateUserProfile); if ($db->NumRowsAffected() > 0) { array_push($aData["records"], $aUser); } else { array_push($aData["message_list"], "An error occurred and we were not able to update you profile, please try again. Error: " . $db->GetError()); } } } else { array_push($aData["message_list"], "Page is allowed only by ajax requests."); } echo json_encode($aData);
<?php error_reporting(E_STRICT); include_once "cls_connection.php"; $db = new ConnectMySql(); $aValues = json_decode(file_get_contents("php://input"), true); $sUsername = $aValues["username"]; $sPassword = md5("WhatdidyousayUser " . $aValues["password"]); $aData = array(); $aData["message_list"] = array(); if ($sUsername !== "") { $sSelect = "select * from wds_users u where u.user_username = '******' and u.user_password = '******'"; $cmd = $db->command($sSelect); if ($db->NumRowsAffected() > 0) { $aData = $db->fetch_array($cmd); } else { array_push($aData["message_list"], "Username {$sUsername} credentials are incorrect or it was not found on DB."); } } else { array_push($aData["message_list"], "Please fill form so we can sign you in."); } echo json_encode($aData);