Beispiel #1
0
                            $trans = 0;
                            $pdo = null;
                        }
                    } catch (PDOException $error) {
                        if ($trans) {
                            $pdo->rollBack();
                            $_POST['error'] = "Transaction failed";
                            echo "Error transaction";
                        } else {
                            $_POST['error'] = "No connection database";
                            echo "Error database";
                        }
                    }
                    if (!image_puttofilepng($img, $file_name, "../images/")) {
                        $_POST['error'] = "Could not save in the file";
                        echo "Error copy to file";
                    } else {
                        if (!image_resized($file_name, "../images/", "../resized/", 0.5)) {
                            $_POST['error'] = "Could not copy resize";
                            echo "Error resize copy";
                        }
                    }
                    unset($pdo, $sql, $pre, $ret, $trans, $file_name, $id, $tag, $meme, $img);
                    if (!isset($_POST['error'])) {
                        echo "Success";
                    }
                }
            }
        }
    }
}
Beispiel #2
0
     $_POST['error'] = "Post not set";
     echo "Error request";
 } else {
     $tag = htmlspecialchars($_POST['tag']);
     $pic64 = $_POST['image'];
     $pos = htmlspecialchars($_POST['pos']);
     $file_name = hash("md5", time() . rand());
     $image = get_imagefrompict($pic64, $file_name, "../images/");
     unset($pic64);
     if ($image !== FALSE) {
         $meme = prepare_posmeme($pos);
         $image = merge_to_finalimg($image, $meme);
         unset($meme, $pos);
         if ($image !== FALSE) {
             if (image_puttofilepng($image, $file_name, "../images/") !== FALSE) {
                 if (image_resized($file_name, "../images/", "../resized/", 0.5) !== FALSE) {
                     $trans = 0;
                     unset($image);
                     try {
                         $pdo = new PDO($DB_DSN, $DB_USER, $DB_PASSWORD);
                         $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                         $pdo->exec("USE db_camagru;");
                         $sql = "SELECT `id` FROM users WHERE `login` = :login;";
                         $pre = $pdo->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
                         $pre->execute(array("login" => $_SESSION['logged_on_us']));
                         $ret = $pre->fetchAll();
                         if (!isset($ret[0]['id'])) {
                             $_POST['error'] = "No id for this login";
                             echo "Error id";
                         } else {
                             $trans = 1;