Exemplo n.º 1
0
function deleteImg($shorten, $api_key)
{
    if (isUrlOwned($shorten, $api_key)) {
        deleteImage($shorten);
    } else {
        echo "Error";
    }
}
$__ROOT__ = dirname(__FILE__) . "/..";
require_once $__ROOT__ . "/lib/lib.php";
if (!isset($_SESSION)) {
    session_start();
}
if (!isset($_GET["d"]) && !isset($_GET["dm"])) {
    header("Location: ..");
    die;
}
$db = getConnexion();
if ($db) {
    if (isset($_GET["d"])) {
        deleteImg($_GET["d"], $_SESSION["api"]);
    } else {
        $images = json_decode($_GET["dm"]);
        foreach ($images as $img) {
            deleteImg($img, $_SESSION["api"]);
        }
    }
    header("Location: ..");
    die;
}
Exemplo n.º 2
0
function insertSports($idUser, $sport1, $sport2, $sport3, $sport4)
{
    try {
        getConnexion()->beginTransaction();
        $req1 = getConnexion()->prepare('INSERT INTO choix VALUES(:sport1, :idUser, 1 )');
        $req1->bindParam(':sport1', $sport1, PDO::PARAM_STR);
        $req1->bindParam(':idUser', $idUser, PDO::PARAM_STR);
        $req1->execute();
        $req2 = getConnexion()->prepare('INSERT INTO choix VALUES(:sport2, :idUser, 2 )');
        $req2->bindParam(':sport2', $sport2, PDO::PARAM_STR);
        $req2->bindParam(':idUser', $idUser, PDO::PARAM_STR);
        $req2->execute();
        $req3 = getConnexion()->prepare('INSERT INTO choix VALUES(:sport3, :idUser, 3 )');
        $req3->bindParam(':sport3', $sport3, PDO::PARAM_STR);
        $req3->bindParam(':idUser', $idUser, PDO::PARAM_STR);
        $req3->execute();
        $req4 = getConnexion()->prepare('INSERT INTO choix VALUES(:sport4, :idUser, 4 )');
        $req4->bindParam(':sport4', $sport4, PDO::PARAM_STR);
        $req4->bindParam(':idUser', $idUser, PDO::PARAM_STR);
        $req4->execute();
        getConnexion()->commit();
        return true;
    } catch (Exception $e) {
        getConnexion()->rollBack();
        return false;
    }
}