Please i need help with this code

Started on the old forum in August 2015 · view the original in the archive · old links redirect here

5 replies · 255 views · started 11 years ago · 1 min read

3 participants
Android404 Junior · 15 posts #1

Hi everyone, i need help with this sniplet.

did a lot of modding etc, just can't get my head around resizing the images. Got them to output successfully.

Please help me in resizing pics?

$height = "100"; //pixels $width = "100"; //pixels

<?php
include("../includes/connect.php");
/*** some basic sanity checks ***/
if(filter_has_var(INPUT_GET, "image_id") !== false && filter_input(INPUT_GET, 'image_id', FILTER_VALIDATE_INT) !== false)
    {
    /*** assign the image id ***/
    $image_id = filter_input(INPUT_GET, "image_id", FILTER_SANITIZE_NUMBER_INT);
    try     {
        /*** connect to the database ***/
        $dbh = new PDO("mysql:host=".$dbhost.";dbname=".$dbname."", "".$dbuser."", "".$dbpass."");

        /*** set the PDO error mode to exception ***/
        $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        /*** The sql statement ***/
        $sql = "SELECT image, image_type FROM products WHERE serial=$image_id";

        /*** prepare the sql ***/
        $stmt = $dbh->prepare($sql);

        /*** exceute the query ***/
        $stmt->execute(); 

        /*** set the fetch mode to associative array ***/
        $stmt->setFetchMode(PDO::FETCH_ASSOC);

        /*** set the header for the image ***/
        $array = $stmt->fetch();

        /*** check we have a single image and type ***/
        if(sizeof($array) == 2)
            {
            /*** set the headers and display the image ***/
            header("Content-type: ".$array['image_type']);

            /*** output the image ***/
            echo $array['image'];
            }
        else
            {
            throw new Exception("<img src=\"../images/demo.png\">");
            }
        }
    catch(PDOException $e)
        {
        echo $e->getMessage();
        }
    catch(Exception $e)
        {
        echo $e->getMessage();
        }
        }
  else
        {
        echo '<img src="../images/demo.png">';
        }
?>
arnage Lead · 811 posts #4

Im even using single thumb file for multiple galleries.

<?php

if (isset($_GET['thumb'], $_GET['gallery'])) {

    $dir = str_replace(chr(92), chr(47), getcwd()) . '/gallery/' . $_GET['gallery'] . '/';

    if (is_dir($dir)) {

        include_once('system/easyphpthumbnail.class.php');

        $thumb = new easyphpthumbnail;

        if ($_GET['gallery'] == 'amsterdam') {

            $thumb -> Thumbwidth = 710;
            $thumb -> Thumbheight = 470;
            $thumb -> Framewidth = 3;
            $thumb -> Framecolor = '#FFFFFF';
            $thumb -> Backgroundcolor = '#D0DEEE';
            $thumb -> Shadow = true;
            $thumb -> Copyrighttext = 'Amsterdam';
            $thumb -> Copyrightposition = '50% 90%';
            $thumb -> Copyrightfonttype = 'fonts/amsfont.ttf';
            $thumb -> Copyrightfontsize = 20;
            $thumb -> Copyrighttextcolor = '#FFFFFF';

        } elseif ($_GET['gallery'] == 'dekoracijezasvadbe') {

            $thumb -> Thumbsize = 200;
            $thumb -> Clipcorner = array(2,15,0,0,1,1,0);

        } elseif ($_GET['gallery'] == '4zoom-clubbing/photos') {

            $thumb -> Thumbwidth = 243;
            $thumb -> Thumbheight = 150;
            $thumb -> Framewidth = 2;
            $thumb -> Framecolor = '#FFFFFF';
            $thumb -> Backgroundcolor = '#D0DEEE';
            $thumb -> Shadow = true;

        } elseif ($_GET['gallery'] == 'jela') {

            $thumb -> Thumbwidth = 490;
            $thumb -> Thumbheight = 440;
            $thumb -> Shadow = true;

        }

        $thumb -> Createthumb($dir . basename($_GET['thumb']));

    } else exit;

}

?>
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
arnage Lead · 811 posts #6

You are welcome. If you need help with it feel free to ask in the topic... </t/8898-easyphpthumbnail-class>

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close